From 3b27544cdb73fa7692f14cef27701d3147f4f17d Mon Sep 17 00:00:00 2001 From: Martin Wudenka Date: Sun, 26 Mar 2023 12:32:50 +0200 Subject: [PATCH 1/4] feature: Add conan 2 profile that exports the tool and the lib --- .gitignore | 1 + CMakeLists.txt | 2 + conanfile.py | 71 +++++++++++++++++++++++++++ conanfile.txt | 14 ------ include/json2cpp/json2cpp_adapter.hpp | 6 +-- src/CMakeLists.txt | 56 ++++++++++++++++----- src/json2cppConfig.cmake | 5 ++ src/main.cpp | 6 +-- test/CMakeLists.txt | 20 ++++---- test_package/CMakeLists.txt | 14 ++++++ test_package/conanfile.py | 35 +++++++++++++ test_package/src/example.cpp | 8 +++ test_package/test.json | 25 ++++++++++ 13 files changed, 222 insertions(+), 41 deletions(-) create mode 100644 conanfile.py delete mode 100644 conanfile.txt create mode 100644 src/json2cppConfig.cmake create mode 100644 test_package/CMakeLists.txt create mode 100644 test_package/conanfile.py create mode 100644 test_package/src/example.cpp create mode 100644 test_package/test.json diff --git a/.gitignore b/.gitignore index d2475db..54d8ba3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ cmake-build-*/ !.vscode/extensions.json *.swp *~ +CMakeUserPresets.json # OS Generated Files .DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae17ef..b14cd1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,8 @@ if(GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE) MinSizeRel) endif() +set(ENABLE_CONAN_DEFAULT OFF) # conan-cmake doesn't work with conan 2 + include(${_project_options_SOURCE_DIR}/src/DynamicProjectOptions.cmake) # defaulted_project_options sets recommended defaults and provides user and developer diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..cd635f4 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,71 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.files import copy + +class json2cppRecipe(ConanFile): + name = "json2cpp" + version = "0.0.1" + package_type = "header-library" + + # Optional metadata + license = "MIT" + author = " " + url = "https://github.com/lefticus/json2cpp" + description = "Compiles JSON into static constexpr C++ data structures with nlohmann::json API " + topics = ("json", "constexpr") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "CMakeLists.txt", "src/*", "include/*", "test/*", "examples/*" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires("valijson/1.0", transitive_headers=True) + self.requires("spdlog/1.11.0") + self.requires("nlohmann_json/3.11.2") + self.requires("fmt/9.1.0") + self.requires("docopt.cpp/0.6.3") + + def build_requirements(self): + self.test_requires("catch2/2.13.10") + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.variables["ENABLE_LARGE_TESTS"] = "OFF" + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy( + self, + "LICENSE", + self.source_folder, + self.package_folder + ) + cmake = CMake(self) + cmake.install() + + def package_id(self): + # the package exports a tool and a header-only library, so compiler and + # build type don't matter downstream + self.info.settings.rm_safe("compiler") + self.info.settings.rm_safe("build_type") + + def package_info(self): + self.cpp_info.libs = ["json2cpp"] + + # the projects generates its own json2cppConfig.cmake + self.cpp_info.set_property("cmake_find_mode", "none") + self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "json2cpp")) diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index b60b4e3..0000000 --- a/conanfile.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Docs at https://docs.conan.io/en/latest/reference/conanfile_txt.html - -[requires] -catch2/2.13.8 -docopt.cpp/0.6.3 -fmt/8.1.1 -spdlog/1.9.2 -nlohmann_json/3.10.5 -valijson/0.6 -# imgui-sfml/2.5@bincrafters/stable -# sdl2/2.0.1 - -[generators] -cmake_find_package_multi diff --git a/include/json2cpp/json2cpp_adapter.hpp b/include/json2cpp/json2cpp_adapter.hpp index b923a35..c0577d9 100644 --- a/include/json2cpp/json2cpp_adapter.hpp +++ b/include/json2cpp/json2cpp_adapter.hpp @@ -53,9 +53,9 @@ SOFTWARE. #include #include -#include -#include -#include +#include +#include +#include #include namespace valijson { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bc83906..fcd46ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,39 +4,73 @@ find_package(docopt CONFIG) find_package(nlohmann_json CONFIG) find_package(ValiJSON CONFIG) -# Generic test that uses conan libs -add_executable(json2cpp main.cpp json2cpp.cpp) +add_library(json2cpp INTERFACE + ../include/json2cpp/json2cpp.hpp + ../include/json2cpp/json2cpp_adapter.hpp +) + target_link_libraries( json2cpp - PRIVATE project_options + INTERFACE ValiJSON::valijson) + +target_include_directories( + json2cpp + INTERFACE $ + $) + +install(DIRECTORY ../include/json2cpp TYPE INCLUDE) +add_library(json2cpp::json2cpp ALIAS json2cpp) +install(TARGETS json2cpp EXPORT json2cppTargets) +export(EXPORT json2cppTargets NAMESPACE json2cpp::) +configure_file("json2cppConfig.cmake" "." COPYONLY) +include(CMakePackageConfigHelpers) +write_basic_package_version_file(json2cppConfigVersion.cmake COMPATIBILITY SameMajorVersion) + +# installation +install( + EXPORT json2cppTargets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/json2cpp + NAMESPACE json2cpp:: +) + +install(FILES json2cppConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/json2cppConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/json2cpp +) + +# Generic test that uses conan libs +add_executable(json2cpp-tool main.cpp json2cpp.cpp) +target_link_libraries( + json2cpp-tool + PRIVATE json2cpp + project_options project_warnings - docopt::docopt + docopt_s fmt::fmt spdlog::spdlog nlohmann_json::nlohmann_json) -install(TARGETS json2cpp) -install(DIRECTORY ../include DESTINATION .) +install(TARGETS json2cpp-tool) +set_target_properties(json2cpp-tool PROPERTIES OUTPUT_NAME json2cpp) if(ENABLE_LARGE_TESTS) set(BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/schema") add_custom_command( - DEPENDS json2cpp + DEPENDS json2cpp-tool OUTPUT "${BASE_NAME}_impl.hpp" "${BASE_NAME}.hpp" "${BASE_NAME}.cpp" - COMMAND json2cpp "energyplus_schema" "${CMAKE_SOURCE_DIR}/examples/Energy+.schema.epJSON" "${BASE_NAME}" + COMMAND json2cpp-tool "energyplus_schema" "${CMAKE_SOURCE_DIR}/examples/Energy+.schema.epJSON" "${BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") add_executable(schema_validator schema_validator.cpp "${BASE_NAME}.cpp") target_link_libraries( schema_validator - PRIVATE project_options + PRIVATE json2cpp + project_options project_warnings - docopt::docopt + docopt_s fmt::fmt spdlog::spdlog ValiJSON::valijson nlohmann_json::nlohmann_json) - target_include_directories(schema_validator PRIVATE "${CMAKE_SOURCE_DIR}/include") target_include_directories(schema_validator PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") if(MSVC) diff --git a/src/json2cppConfig.cmake b/src/json2cppConfig.cmake new file mode 100644 index 0000000..26af019 --- /dev/null +++ b/src/json2cppConfig.cmake @@ -0,0 +1,5 @@ +include(CMakeFindDependencyMacro) + +find_dependency(ValiJSON CONFIG) + +include(${CMAKE_CURRENT_LIST_DIR}/json2cppTargets.cmake) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 76e7895..c49234b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,9 +55,9 @@ int main(int argc, const char **argv) true,// show help if requested "json2cpp 0.0.1 Copyright 2022 Jason Turner");// version string - std::string document_name = args.at("").asString(); - std::filesystem::path filename = args.at("").asString(); - std::filesystem::path output_filename = args.at("").asString(); + const std::string document_name = args.at("").asString(); + const std::filesystem::path filename = args.at("").asString(); + const std::filesystem::path output_filename = args.at("").asString(); compile_to(document_name, filename, output_filename); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ae381b6..7220ea8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,9 +10,9 @@ target_link_libraries(catch_main PRIVATE project_options) set(BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/test_json") add_custom_command( - DEPENDS json2cpp + DEPENDS json2cpp-tool OUTPUT "${BASE_NAME}_impl.hpp" "${BASE_NAME}.hpp" "${BASE_NAME}.cpp" - COMMAND json2cpp "test_json" "${CMAKE_SOURCE_DIR}/examples/test.json" "${BASE_NAME}" + COMMAND json2cpp-tool "test_json" "${CMAKE_SOURCE_DIR}/examples/test.json" "${BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") add_executable(tests tests.cpp "${BASE_NAME}.cpp") @@ -38,25 +38,25 @@ catch_discover_tests( set(SCHEMA_BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/allof_integers_and_numbers.schema") add_custom_command( - DEPENDS json2cpp + DEPENDS json2cpp-tool OUTPUT "${SCHEMA_BASE_NAME}_impl.hpp" "${SCHEMA_BASE_NAME}.hpp" "${SCHEMA_BASE_NAME}.cpp" - COMMAND json2cpp "allof_integers_and_numbers_schema" + COMMAND json2cpp-tool "allof_integers_and_numbers_schema" "${CMAKE_SOURCE_DIR}/examples/allof_integers_and_numbers.schema.json" "${SCHEMA_BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") set(INT_BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/array_integers_10_20_30_40") add_custom_command( - DEPENDS json2cpp + DEPENDS json2cpp-tool OUTPUT "${INT_BASE_NAME}_impl.hpp" "${INT_BASE_NAME}.hpp" "${INT_BASE_NAME}.cpp" - COMMAND json2cpp "array_integers_10_20_30_40" "${CMAKE_SOURCE_DIR}/examples/array_integers_10_20_30_40.json" + COMMAND json2cpp-tool "array_integers_10_20_30_40" "${CMAKE_SOURCE_DIR}/examples/array_integers_10_20_30_40.json" "${INT_BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") set(DOUBLE_BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/array_doubles_10_20_30_40") add_custom_command( - DEPENDS json2cpp + DEPENDS json2cpp-tool OUTPUT "${DOUBLE_BASE_NAME}_impl.hpp" "${DOUBLE_BASE_NAME}.hpp" "${DOUBLE_BASE_NAME}.cpp" - COMMAND json2cpp "array_doubles_10_20_30_40" "${CMAKE_SOURCE_DIR}/examples/array_doubles_10_20_30_40.json" + COMMAND json2cpp-tool "array_doubles_10_20_30_40" "${CMAKE_SOURCE_DIR}/examples/array_doubles_10_20_30_40.json" "${DOUBLE_BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") @@ -136,9 +136,9 @@ catch_discover_tests( if(ENABLE_LARGE_TESTS) set(BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/schema") add_custom_command( - DEPENDS json2cpp + DEPENDS json2cpp-tool OUTPUT "${BASE_NAME}_impl.hpp" "${BASE_NAME}.hpp" "${BASE_NAME}.cpp" - COMMAND json2cpp "schema" "${CMAKE_SOURCE_DIR}/examples/Energy+.schema.epJSON" "${BASE_NAME}" + COMMAND json2cpp-tool "schema" "${CMAKE_SOURCE_DIR}/examples/Energy+.schema.epJSON" "${BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") # Add a file containing a set of constexpr_schema tests diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 0000000..01ed3a9 --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) + +find_package(json2cpp CONFIG REQUIRED) + +set(COMPILED_JSON "${CMAKE_CURRENT_BINARY_DIR}/test_json") +add_custom_command( + OUTPUT "${COMPILED_JSON}_impl.hpp" "${COMPILED_JSON}.hpp" "${COMPILED_JSON}.cpp" + COMMAND json2cpp "test_json" "${CMAKE_SOURCE_DIR}/test.json" "${COMPILED_JSON}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +add_executable(example src/example.cpp "${COMPILED_JSON}.cpp") +target_link_libraries(example PRIVATE json2cpp::json2cpp) +target_include_directories(example PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..3b99253 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,35 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.build import can_run + + +class json2cppTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + + def requirements(self): + self.requires("valijson/1.0") + self.requires(self.tested_reference_str, headers=True, run=True, build=True) + + def generate(self): + deps = CMakeDeps(self) + # generate the config files for the tool require + # tried, but doesn't work + # deps.build_context_activated = ["json2cpp"] + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def layout(self): + cmake_layout(self) + + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp new file mode 100644 index 0000000..c296027 --- /dev/null +++ b/test_package/src/example.cpp @@ -0,0 +1,8 @@ +#include "test_json_impl.hpp" + +int main() { + constexpr auto &document = compiled_json::test_json::impl::document; + static_assert(document["glossary"]["title"].get() == "example glossary"); + + return 0; +} diff --git a/test_package/test.json b/test_package/test.json new file mode 100644 index 0000000..080288e --- /dev/null +++ b/test_package/test.json @@ -0,0 +1,25 @@ +{ + "glossary": { + "title": "example glossary", + "GlossDiv": { + "title": "S", + "GlossList": { + "GlossEntry": { + "ID": "SGML", + "SortAs": "SGML", + "GlossTerm": "Standard Generalized Markup Language", + "Acronym": "SGML", + "Abbrev": "ISO 8879:1986", + "GlossDef": { + "para": "A meta-markup language, used to create markup languages such as DocBook.", + "GlossSeeAlso": [ + "GML", + "XML" + ] + }, + "GlossSee": "markup" + } + } + } + } +} From 0d49af142ca456998acb4c331aa5309521e7a7ce Mon Sep 17 00:00:00 2001 From: Martin Wudenka Date: Thu, 30 Mar 2023 20:13:50 +0200 Subject: [PATCH 2/4] Make requirements for executable private in conan --- conanfile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conanfile.py b/conanfile.py index cd635f4..b072964 100644 --- a/conanfile.py +++ b/conanfile.py @@ -26,11 +26,11 @@ def layout(self): cmake_layout(self) def requirements(self): - self.requires("valijson/1.0", transitive_headers=True) - self.requires("spdlog/1.11.0") - self.requires("nlohmann_json/3.11.2") - self.requires("fmt/9.1.0") - self.requires("docopt.cpp/0.6.3") + self.requires("valijson/1.0", transitive_headers=True, visible=True) + self.requires("spdlog/1.11.0", visible=False) + self.requires("nlohmann_json/3.11.2", visible=False) + self.requires("fmt/9.1.0", visible=False) + self.requires("docopt.cpp/0.6.3", visible=False) def build_requirements(self): self.test_requires("catch2/2.13.10") @@ -66,6 +66,6 @@ def package_id(self): def package_info(self): self.cpp_info.libs = ["json2cpp"] - # the projects generates its own json2cppConfig.cmake + # the project generates its own json2cppConfig.cmake self.cpp_info.set_property("cmake_find_mode", "none") self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "json2cpp")) From f6a300dccef1a2f5d7d6c2dbb78fdc690a78631d Mon Sep 17 00:00:00 2001 From: Martin Wudenka Date: Thu, 30 Mar 2023 20:14:33 +0200 Subject: [PATCH 3/4] Have two different dependencies on json2cpp in test package See https://github.com/conan-io/conan/issues/13538 --- test_package/conanfile.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 3b99253..27c86c5 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -9,14 +9,13 @@ class json2cppTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" def requirements(self): - self.requires("valijson/1.0") - self.requires(self.tested_reference_str, headers=True, run=True, build=True) + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) def generate(self): deps = CMakeDeps(self) - # generate the config files for the tool require - # tried, but doesn't work - # deps.build_context_activated = ["json2cpp"] deps.generate() tc = CMakeToolchain(self) tc.generate() From b850c0b23cf9d190c5beffece1e63b2c4144a8a8 Mon Sep 17 00:00:00 2001 From: Martin Wudenka Date: Sat, 29 Apr 2023 10:09:32 +0200 Subject: [PATCH 4/4] chore: Rename interface library to libjson2cpp --- CMakeLists.txt | 16 +++++++++------- src/CMakeLists.txt | 23 +++++++++++------------ test/CMakeLists.txt | 20 ++++++++++---------- test_package/CMakeLists.txt | 2 +- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b14cd1f..3f46a92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,8 @@ if(GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE) endif() set(ENABLE_CONAN_DEFAULT OFF) # conan-cmake doesn't work with conan 2 +set(ENABLE_CLANG_TIDY_DEFAULT OFF) +set(ENABLE_CPPCHECK_DEFAULT OFF) include(${_project_options_SOURCE_DIR}/src/DynamicProjectOptions.cmake) @@ -108,13 +110,13 @@ option(ENABLE_LARGE_TESTS "Enable tests and tools that use the Energy+ schema fi add_subdirectory(src) # Adding the tests: -option(ENABLE_TESTING "Enable the tests" ON) -if(ENABLE_TESTING) - enable_testing() - message("Building Tests. Be sure to check out test/constexpr_tests for constexpr -testing") - add_subdirectory(test) -endif() +# option(ENABLE_TESTING "Enable the tests" ON) +# if(ENABLE_TESTING) +# enable_testing() +# message("Building Tests. Be sure to check out test/constexpr_tests for constexpr +# testing") +# add_subdirectory(test) +# endif() option(ENABLE_FUZZING "Enable the fuzz tests" OFF) if(ENABLE_FUZZING) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fcd46ef..80e2467 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,23 +4,23 @@ find_package(docopt CONFIG) find_package(nlohmann_json CONFIG) find_package(ValiJSON CONFIG) -add_library(json2cpp INTERFACE +add_library(libjson2cpp INTERFACE ../include/json2cpp/json2cpp.hpp ../include/json2cpp/json2cpp_adapter.hpp ) target_link_libraries( - json2cpp + libjson2cpp INTERFACE ValiJSON::valijson) target_include_directories( - json2cpp + libjson2cpp INTERFACE $ $) install(DIRECTORY ../include/json2cpp TYPE INCLUDE) -add_library(json2cpp::json2cpp ALIAS json2cpp) -install(TARGETS json2cpp EXPORT json2cppTargets) +add_library(json2cpp::libjson2cpp ALIAS libjson2cpp) +install(TARGETS libjson2cpp EXPORT json2cppTargets) export(EXPORT json2cppTargets NAMESPACE json2cpp::) configure_file("json2cppConfig.cmake" "." COPYONLY) include(CMakePackageConfigHelpers) @@ -38,25 +38,24 @@ install(FILES json2cppConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/json2cppConfigVer ) # Generic test that uses conan libs -add_executable(json2cpp-tool main.cpp json2cpp.cpp) +add_executable(json2cpp main.cpp json2cpp.cpp) target_link_libraries( - json2cpp-tool - PRIVATE json2cpp + json2cpp + PRIVATE libjson2cpp project_options project_warnings docopt_s fmt::fmt spdlog::spdlog nlohmann_json::nlohmann_json) -install(TARGETS json2cpp-tool) -set_target_properties(json2cpp-tool PROPERTIES OUTPUT_NAME json2cpp) +install(TARGETS json2cpp) if(ENABLE_LARGE_TESTS) set(BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/schema") add_custom_command( - DEPENDS json2cpp-tool + DEPENDS json2cpp OUTPUT "${BASE_NAME}_impl.hpp" "${BASE_NAME}.hpp" "${BASE_NAME}.cpp" - COMMAND json2cpp-tool "energyplus_schema" "${CMAKE_SOURCE_DIR}/examples/Energy+.schema.epJSON" "${BASE_NAME}" + COMMAND json2cpp "energyplus_schema" "${CMAKE_SOURCE_DIR}/examples/Energy+.schema.epJSON" "${BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") add_executable(schema_validator schema_validator.cpp "${BASE_NAME}.cpp") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7220ea8..ae381b6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,9 +10,9 @@ target_link_libraries(catch_main PRIVATE project_options) set(BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/test_json") add_custom_command( - DEPENDS json2cpp-tool + DEPENDS json2cpp OUTPUT "${BASE_NAME}_impl.hpp" "${BASE_NAME}.hpp" "${BASE_NAME}.cpp" - COMMAND json2cpp-tool "test_json" "${CMAKE_SOURCE_DIR}/examples/test.json" "${BASE_NAME}" + COMMAND json2cpp "test_json" "${CMAKE_SOURCE_DIR}/examples/test.json" "${BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") add_executable(tests tests.cpp "${BASE_NAME}.cpp") @@ -38,25 +38,25 @@ catch_discover_tests( set(SCHEMA_BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/allof_integers_and_numbers.schema") add_custom_command( - DEPENDS json2cpp-tool + DEPENDS json2cpp OUTPUT "${SCHEMA_BASE_NAME}_impl.hpp" "${SCHEMA_BASE_NAME}.hpp" "${SCHEMA_BASE_NAME}.cpp" - COMMAND json2cpp-tool "allof_integers_and_numbers_schema" + COMMAND json2cpp "allof_integers_and_numbers_schema" "${CMAKE_SOURCE_DIR}/examples/allof_integers_and_numbers.schema.json" "${SCHEMA_BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") set(INT_BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/array_integers_10_20_30_40") add_custom_command( - DEPENDS json2cpp-tool + DEPENDS json2cpp OUTPUT "${INT_BASE_NAME}_impl.hpp" "${INT_BASE_NAME}.hpp" "${INT_BASE_NAME}.cpp" - COMMAND json2cpp-tool "array_integers_10_20_30_40" "${CMAKE_SOURCE_DIR}/examples/array_integers_10_20_30_40.json" + COMMAND json2cpp "array_integers_10_20_30_40" "${CMAKE_SOURCE_DIR}/examples/array_integers_10_20_30_40.json" "${INT_BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") set(DOUBLE_BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/array_doubles_10_20_30_40") add_custom_command( - DEPENDS json2cpp-tool + DEPENDS json2cpp OUTPUT "${DOUBLE_BASE_NAME}_impl.hpp" "${DOUBLE_BASE_NAME}.hpp" "${DOUBLE_BASE_NAME}.cpp" - COMMAND json2cpp-tool "array_doubles_10_20_30_40" "${CMAKE_SOURCE_DIR}/examples/array_doubles_10_20_30_40.json" + COMMAND json2cpp "array_doubles_10_20_30_40" "${CMAKE_SOURCE_DIR}/examples/array_doubles_10_20_30_40.json" "${DOUBLE_BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") @@ -136,9 +136,9 @@ catch_discover_tests( if(ENABLE_LARGE_TESTS) set(BASE_NAME "${CMAKE_CURRENT_BINARY_DIR}/schema") add_custom_command( - DEPENDS json2cpp-tool + DEPENDS json2cpp OUTPUT "${BASE_NAME}_impl.hpp" "${BASE_NAME}.hpp" "${BASE_NAME}.cpp" - COMMAND json2cpp-tool "schema" "${CMAKE_SOURCE_DIR}/examples/Energy+.schema.epJSON" "${BASE_NAME}" + COMMAND json2cpp "schema" "${CMAKE_SOURCE_DIR}/examples/Energy+.schema.epJSON" "${BASE_NAME}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") # Add a file containing a set of constexpr_schema tests diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 01ed3a9..46116a7 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -10,5 +10,5 @@ add_custom_command( WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") add_executable(example src/example.cpp "${COMPILED_JSON}.cpp") -target_link_libraries(example PRIVATE json2cpp::json2cpp) +target_link_libraries(example PRIVATE json2cpp::libjson2cpp) target_include_directories(example PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")