Add appropriate project version evaluation

Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
This commit is contained in:
Cristian Le 2023-05-10 18:49:50 +02:00
parent 60603f6c8d
commit ff35afd5a5
Failed to extract signature
3 changed files with 9 additions and 4 deletions

View File

@ -8,13 +8,15 @@ target_sources(nlohmann_json_schema_validator PRIVATE
)
target_sources(nlohmann_json_schema_validator_cli PRIVATE
cli.cpp)
configure_file(nlohmann/json-schema.hpp.in nlohmann/json-schema.hpp)
target_include_directories(nlohmann_json_schema_validator PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)
set_target_properties(nlohmann_json_schema_validator PROPERTIES
PUBLIC_HEADER nlohmann/json-schema.hpp)
PUBLIC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/nlohmann/json-schema.hpp)
target_link_libraries(nlohmann_json_schema_validator_cli PRIVATE
nlohmann_json_schema_validator CLI11::CLI11)

View File

@ -10,6 +10,7 @@ using namespace nlohmann::json_schema;
class main_cli : public CLI::App
{
std::string version;
std::ifstream schema_input;
std::filesystem::path object_path;
// TODO: Export this as a built-in loader
@ -34,10 +35,10 @@ public:
: CLI::App{"Json schema validator", "json-validator"},
validator{
[this](const json_uri &u, json &s) { this->loader(u, s); },
default_string_format_check}
default_string_format_check},
version{nlohmann::json_schema::version}
{
// TODO: Move to a generated header file
set_version_flag("--version", "2.2.0");
set_version_flag("--version", version);
add_option("schema", schema_input, "JSON schema of the object")
->check(CLI::ExistingFile);
add_option("object", object_path, "JSON object to validate")

View File

@ -128,6 +128,8 @@ public:
namespace json_schema
{
constexpr std::string_view version = "@PROJECT_VERSION@";
extern json draft7_schema_builtin;
typedef std::function<void(const json_uri & /*id*/, json & /*value*/)> schema_loader;