2017-10-18 23:07:17 +02:00
|
|
|
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
|
|
|
|
|
|
|
# metadata
|
2017-10-25 17:41:19 +02:00
|
|
|
set(META_PROJECT_NAME reflective_rapidjson_generator)
|
2017-10-18 23:07:17 +02:00
|
|
|
set(META_PROJECT_TYPE application)
|
|
|
|
set(LINK_TESTS_AGAINST_APP_TARGET ON)
|
|
|
|
|
|
|
|
# add project files
|
|
|
|
set(HEADER_FILES
|
2017-10-25 15:38:45 +02:00
|
|
|
codegenerator.h
|
2017-10-28 16:31:07 +02:00
|
|
|
jsonserializationcodegenerator.h
|
2017-10-25 15:38:45 +02:00
|
|
|
codefactory.h
|
2017-10-21 00:32:42 +02:00
|
|
|
frontendaction.h
|
|
|
|
consumer.h
|
|
|
|
visitor.h
|
|
|
|
clangversionabstraction.h
|
2017-10-18 23:07:17 +02:00
|
|
|
)
|
|
|
|
set(SRC_FILES
|
2017-10-25 15:38:45 +02:00
|
|
|
codegenerator.cpp
|
2017-10-28 16:31:07 +02:00
|
|
|
jsonserializationcodegenerator.cpp
|
2017-10-25 15:38:45 +02:00
|
|
|
codefactory.cpp
|
2017-10-21 00:32:42 +02:00
|
|
|
frontendaction.cpp
|
|
|
|
consumer.cpp
|
|
|
|
clangversionabstraction.cpp
|
|
|
|
visitor.cpp
|
2017-10-18 23:07:17 +02:00
|
|
|
main.cpp
|
|
|
|
)
|
|
|
|
set(TEST_HEADER_FILES
|
2017-10-25 18:25:34 +02:00
|
|
|
tests/helper.h
|
2017-10-18 23:07:17 +02:00
|
|
|
)
|
|
|
|
set(TEST_SRC_FILES
|
|
|
|
tests/cppunit.cpp
|
|
|
|
)
|
|
|
|
|
2017-11-17 22:04:01 +01:00
|
|
|
# add JSON-specific test cases
|
|
|
|
if(RapidJSON_FOUND)
|
|
|
|
list(APPEND TEST_HEADER_FILES
|
|
|
|
tests/structs.h
|
2017-12-31 00:37:30 +01:00
|
|
|
tests/morestructs.h
|
2017-11-17 22:04:01 +01:00
|
|
|
)
|
|
|
|
list(APPEND TEST_SRC_FILES
|
|
|
|
tests/jsongenerator.cpp
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-11-17 21:21:34 +01:00
|
|
|
# link against c++utilities
|
2017-10-18 23:07:17 +02:00
|
|
|
use_cpp_utilities()
|
|
|
|
|
2017-10-28 18:24:12 +02:00
|
|
|
# find Clang for LibTooling; adding clangTooling should be sufficient as it pulls all transitive dependencies
|
2017-10-18 23:07:17 +02:00
|
|
|
find_package(Clang REQUIRED)
|
2017-10-21 00:32:42 +02:00
|
|
|
list(APPEND PRIVATE_LIBRARIES clangTooling)
|
|
|
|
|
2017-10-28 18:24:12 +02:00
|
|
|
# also add reflective_rapidjson which is header-only but might pull additional include dirs for RapidJSON
|
2017-10-18 23:07:17 +02:00
|
|
|
list(APPEND PRIVATE_LIBRARIES reflective_rapidjson)
|
|
|
|
|
2017-11-03 22:41:51 +01:00
|
|
|
# include modules to apply configuration
|
|
|
|
include(BasicConfig)
|
|
|
|
include(WindowsResources)
|
|
|
|
include(AppTarget)
|
2017-10-18 23:07:17 +02:00
|
|
|
include(TestTarget)
|
|
|
|
include(ShellCompletion)
|
2017-10-23 00:41:10 +02:00
|
|
|
include(Doxygen)
|
2017-11-17 22:01:18 +01:00
|
|
|
|
2018-01-20 19:46:17 +01:00
|
|
|
# trigger code generator for tests because the tests already contain structs to be (de)serialized
|
|
|
|
if(TARGET reflective_rapidjson_generator_tests)
|
|
|
|
include(ReflectionGenerator)
|
|
|
|
add_reflection_generator_invocation(
|
|
|
|
INPUT_FILES
|
|
|
|
tests/structs.h # used by test cases
|
|
|
|
tests/morestructs.h # used by test cases
|
|
|
|
tests/cppunit.cpp # just for testing multiple input files and the "empty file" case
|
|
|
|
GENERATORS
|
|
|
|
json
|
|
|
|
OUTPUT_LISTS
|
|
|
|
TEST_GENERATED_HEADER_FILES
|
|
|
|
CLANG_OPTIONS_FROM_TARGETS
|
|
|
|
reflective_rapidjson_generator_tests
|
|
|
|
JSON_CLASSES
|
|
|
|
OtherNotJsonSerializable # test specifying classes for JSON (de)serialization manually
|
|
|
|
SomeOtherClassName # specifying a class that does not exist should not cause any problems
|
|
|
|
JSON_VISIBILITY
|
|
|
|
LIB_EXPORT # not required, just to test setting visibility
|
|
|
|
)
|
|
|
|
list(APPEND TEST_HEADER_FILES ${TEST_GENERATED_HEADER_FILES})
|
|
|
|
target_sources(reflective_rapidjson_generator_tests PRIVATE ${TEST_GENERATED_HEADER_FILES})
|
|
|
|
endif()
|
|
|
|
|
2017-11-17 22:01:18 +01:00
|
|
|
# add paths for include dirs of c++utilities and RapidJSON to config header so test cases can use it
|
|
|
|
set(META_CUSTOM_CONFIG "#define CPP_UTILITIES_INCLUDE_DIRS \"${CPP_UTILITIES_INCLUDE_DIRS}\"\n")
|
|
|
|
if(RapidJSON_FOUND)
|
|
|
|
string(APPEND META_CUSTOM_CONFIG "#define RAPIDJSON_INCLUDE_DIRS \"${RAPIDJSON_INCLUDE_DIRS}\"\n")
|
|
|
|
endif()
|
|
|
|
|
2018-02-03 15:44:10 +01:00
|
|
|
# add path of Clang's resource dir to config header so test cases can use it
|
|
|
|
string(APPEND META_CUSTOM_CONFIG "#define REFLECTION_GENERATOR_CLANG_RESOURCE_DIR \"${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}\"\n")
|
|
|
|
|
2017-11-17 22:01:18 +01:00
|
|
|
# make config header
|
2017-10-18 23:07:17 +02:00
|
|
|
include(ConfigHeader)
|
2017-11-17 22:01:18 +01:00
|
|
|
|