-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up install files and add install/find_package testing to ci wor…
…kflow (#155) Co-authored-by: Stephen Berry <stephenberry.developer@gmail.com>
- Loading branch information
1 parent
ed8ae2a
commit a12ef30
Showing
7 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.18) | ||
|
||
project( | ||
glaze_example | ||
VERSION 0.0.1 | ||
LANGUAGES CXX | ||
) | ||
|
||
file(GLOB srcs src/*.cpp include/*.hpp) | ||
|
||
find_package(glaze REQUIRED) | ||
|
||
add_executable(${PROJECT_NAME} ${srcs}) | ||
target_include_directories(${PROJECT_NAME} PRIVATE include) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE glaze::glaze) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include "glaze/glaze.hpp" | ||
|
||
namespace example | ||
{ | ||
struct person | ||
{ | ||
std::string first_name{}; | ||
std::string last_name{}; | ||
uint32_t age{}; | ||
}; | ||
} | ||
|
||
template <> | ||
struct glz::meta<example::person> | ||
{ | ||
using T = example::person; | ||
static constexpr auto value = object("first_name", &T::first_name, "last_name", &T::last_name, "age", &T::age); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "example.hpp" | ||
|
||
int main() | ||
{ | ||
using namespace example; | ||
std::vector<person> directory; | ||
directory.emplace_back(person{"John", "Doe", 33}); | ||
directory.emplace_back(person{"Alice", "Right", 22}); | ||
|
||
std::string buffer{}; | ||
glz::write_json(directory, buffer); | ||
|
||
std::cout << buffer << "\n\n"; | ||
|
||
std::array<person, 2> another_directory; | ||
glz::read_json(another_directory, buffer); | ||
|
||
std::string another_buffer{}; | ||
glz::write_json(another_directory, another_buffer); | ||
|
||
if (buffer == another_buffer) { | ||
std::cout << "Directories are the same!\n"; | ||
} | ||
|
||
return 0; | ||
} |
This is wrong and breaks compatibility with vendoring (eg. FetchContent)! Vendoring projects now will install glaze directly to
/usr/local/include
if/usr/local
is their install prefix and wish to install glaze themselves. Explanation why there is an additional subdir when installing: friendlyanon/cmake-init#43Example where this could go wrong:
This breaks
#include <glaze/glaze.hpp>
includes!