Separate RapidJSON specific parts

So when extending this for further applications of
reflection, the JSON-specific parts can be made optional.
This commit is contained in:
Martchus 2017-11-17 22:04:01 +01:00
parent 8c3dd5535d
commit f5a240649f
3 changed files with 32 additions and 13 deletions

View File

@ -52,6 +52,12 @@ if(BUNDLED_CPP_UTILITIES_PATH)
set(CPP_UTILITIES_INCLUDE_DIRS "${CPP_UTILITIES_SOURCE_DIR}/..")
endif()
# find RapidJSON
find_package(RapidJSON)
if(NOT RapidJSON_FOUND)
message(FATAL_ERROR "Unable to find RapidJSON. Since this is the only supported reflection application at this time, it makes no sense to continue.")
endif()
# add header-only library containing JsonSerializable and helper for using RapidJSON
add_subdirectory(lib)
# allow inclusion of CMake modules from that lib in other parts of the project

View File

@ -26,14 +26,22 @@ set(SRC_FILES
main.cpp
)
set(TEST_HEADER_FILES
tests/structs.h
tests/helper.h
)
set(TEST_SRC_FILES
tests/cppunit.cpp
tests/jsongenerator.cpp
)
# add JSON-specific test cases
if(RapidJSON_FOUND)
list(APPEND TEST_HEADER_FILES
tests/structs.h
)
list(APPEND TEST_SRC_FILES
tests/jsongenerator.cpp
)
endif()
# link against c++utilities
use_cpp_utilities()

View File

@ -5,11 +5,6 @@ set(META_PROJECT_TYPE library)
# add project files
set(HEADER_FILES
json/reflector.h
json/reflector-boosthana.h
json/reflector-chronoutilities.h
json/serializable.h
json/errorhandling.h
)
set(SRC_FILES
)
@ -17,9 +12,6 @@ set(TEST_HEADER_FILES
)
set(TEST_SRC_FILES
tests/cppunit.cpp
tests/jsonreflector.cpp
tests/jsonreflector-boosthana.cpp
tests/jsonreflector-chronoutilities.cpp
)
set(CMAKE_MODULE_FILES
cmake/modules/ReflectionGenerator.cmake
@ -28,17 +20,30 @@ set(DOC_FILES
README.md
)
# add JSON-specific sources
if(RapidJSON_FOUND)
list(APPEND HEADER_FILES
json/reflector.h
json/reflector-boosthana.h
json/reflector-chronoutilities.h
json/serializable.h
json/errorhandling.h
)
list(APPEND TEST_SRC_FILES
tests/jsonreflector.cpp
tests/jsonreflector-boosthana.cpp
tests/jsonreflector-chronoutilities.cpp
)
endif()
# add (only) the include dirs for c++utilities because we're not depending on the actual library
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}")
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}")
# find RapidJSON, also add only the include dirs because RapidJSON is a header-only library
find_package(RapidJSON)
if(RapidJSON_FOUND)
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS})
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Unable to find RapidJSON. Since this is the only reflection application supported at this time it makes no sense to continue.")
endif()
# include modules to apply configuration