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:
parent
8c3dd5535d
commit
f5a240649f
|
@ -52,6 +52,12 @@ if(BUNDLED_CPP_UTILITIES_PATH)
|
||||||
set(CPP_UTILITIES_INCLUDE_DIRS "${CPP_UTILITIES_SOURCE_DIR}/..")
|
set(CPP_UTILITIES_INCLUDE_DIRS "${CPP_UTILITIES_SOURCE_DIR}/..")
|
||||||
endif()
|
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 header-only library containing JsonSerializable and helper for using RapidJSON
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
# allow inclusion of CMake modules from that lib in other parts of the project
|
# allow inclusion of CMake modules from that lib in other parts of the project
|
||||||
|
|
|
@ -26,14 +26,22 @@ set(SRC_FILES
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
set(TEST_HEADER_FILES
|
set(TEST_HEADER_FILES
|
||||||
tests/structs.h
|
|
||||||
tests/helper.h
|
tests/helper.h
|
||||||
)
|
)
|
||||||
set(TEST_SRC_FILES
|
set(TEST_SRC_FILES
|
||||||
tests/cppunit.cpp
|
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
|
# link against c++utilities
|
||||||
use_cpp_utilities()
|
use_cpp_utilities()
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,6 @@ set(META_PROJECT_TYPE library)
|
||||||
|
|
||||||
# add project files
|
# add project files
|
||||||
set(HEADER_FILES
|
set(HEADER_FILES
|
||||||
json/reflector.h
|
|
||||||
json/reflector-boosthana.h
|
|
||||||
json/reflector-chronoutilities.h
|
|
||||||
json/serializable.h
|
|
||||||
json/errorhandling.h
|
|
||||||
)
|
)
|
||||||
set(SRC_FILES
|
set(SRC_FILES
|
||||||
)
|
)
|
||||||
|
@ -17,9 +12,6 @@ set(TEST_HEADER_FILES
|
||||||
)
|
)
|
||||||
set(TEST_SRC_FILES
|
set(TEST_SRC_FILES
|
||||||
tests/cppunit.cpp
|
tests/cppunit.cpp
|
||||||
tests/jsonreflector.cpp
|
|
||||||
tests/jsonreflector-boosthana.cpp
|
|
||||||
tests/jsonreflector-chronoutilities.cpp
|
|
||||||
)
|
)
|
||||||
set(CMAKE_MODULE_FILES
|
set(CMAKE_MODULE_FILES
|
||||||
cmake/modules/ReflectionGenerator.cmake
|
cmake/modules/ReflectionGenerator.cmake
|
||||||
|
@ -28,17 +20,30 @@ set(DOC_FILES
|
||||||
README.md
|
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
|
# 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_SHARED_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}")
|
||||||
list(APPEND PUBLIC_STATIC_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 RapidJSON, also add only the include dirs because RapidJSON is a header-only library
|
||||||
find_package(RapidJSON)
|
|
||||||
if(RapidJSON_FOUND)
|
if(RapidJSON_FOUND)
|
||||||
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS})
|
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS})
|
||||||
list(APPEND PUBLIC_STATIC_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()
|
endif()
|
||||||
|
|
||||||
# include modules to apply configuration
|
# include modules to apply configuration
|
||||||
|
|
Loading…
Reference in New Issue