Add appropriate project version evaluation
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
This commit is contained in:
parent
60603f6c8d
commit
ff35afd5a5
@ -8,13 +8,15 @@ target_sources(nlohmann_json_schema_validator PRIVATE
|
|||||||
)
|
)
|
||||||
target_sources(nlohmann_json_schema_validator_cli PRIVATE
|
target_sources(nlohmann_json_schema_validator_cli PRIVATE
|
||||||
cli.cpp)
|
cli.cpp)
|
||||||
|
configure_file(nlohmann/json-schema.hpp.in nlohmann/json-schema.hpp)
|
||||||
|
|
||||||
target_include_directories(nlohmann_json_schema_validator PUBLIC
|
target_include_directories(nlohmann_json_schema_validator PUBLIC
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||||
)
|
)
|
||||||
set_target_properties(nlohmann_json_schema_validator PROPERTIES
|
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
|
target_link_libraries(nlohmann_json_schema_validator_cli PRIVATE
|
||||||
nlohmann_json_schema_validator CLI11::CLI11)
|
nlohmann_json_schema_validator CLI11::CLI11)
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ using namespace nlohmann::json_schema;
|
|||||||
|
|
||||||
class main_cli : public CLI::App
|
class main_cli : public CLI::App
|
||||||
{
|
{
|
||||||
|
std::string version;
|
||||||
std::ifstream schema_input;
|
std::ifstream schema_input;
|
||||||
std::filesystem::path object_path;
|
std::filesystem::path object_path;
|
||||||
// TODO: Export this as a built-in loader
|
// TODO: Export this as a built-in loader
|
||||||
@ -34,10 +35,10 @@ public:
|
|||||||
: CLI::App{"Json schema validator", "json-validator"},
|
: CLI::App{"Json schema validator", "json-validator"},
|
||||||
validator{
|
validator{
|
||||||
[this](const json_uri &u, json &s) { this->loader(u, s); },
|
[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", version);
|
||||||
set_version_flag("--version", "2.2.0");
|
|
||||||
add_option("schema", schema_input, "JSON schema of the object")
|
add_option("schema", schema_input, "JSON schema of the object")
|
||||||
->check(CLI::ExistingFile);
|
->check(CLI::ExistingFile);
|
||||||
add_option("object", object_path, "JSON object to validate")
|
add_option("object", object_path, "JSON object to validate")
|
||||||
|
|||||||
@ -128,6 +128,8 @@ public:
|
|||||||
namespace json_schema
|
namespace json_schema
|
||||||
{
|
{
|
||||||
|
|
||||||
|
constexpr std::string_view version = "@PROJECT_VERSION@";
|
||||||
|
|
||||||
extern json draft7_schema_builtin;
|
extern json draft7_schema_builtin;
|
||||||
|
|
||||||
typedef std::function<void(const json_uri & /*id*/, json & /*value*/)> schema_loader;
|
typedef std::function<void(const json_uri & /*id*/, json & /*value*/)> schema_loader;
|
||||||
Loading…
Reference in New Issue
Block a user