Fix build so that test_suite is always compiled and linked against embedded json11 and jsoncpp libraries

This commit is contained in:
Tristan Penman 2016-08-10 21:15:18 -07:00
parent fe7e19494c
commit f01916571f

View File

@ -35,11 +35,23 @@ add_library(jsoncpp
thirdparty/jsoncpp-0.9.4/src/lib_json/json_writer.cpp
)
if(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED)
add_library(json11
thirdparty/json11-2016-01-26/json11.cpp
)
endif()
target_include_directories(jsoncpp SYSTEM PRIVATE
thirdparty/jsoncpp-0.9.4/include
)
set_target_properties(jsoncpp PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/thirdparty/jsoncpp-0.9.4)
add_library(json11
thirdparty/json11-2016-01-26/json11.cpp
)
target_include_directories(json11 SYSTEM PRIVATE
thirdparty/json11-2016-01-26
)
set_target_properties(json11 PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/thirdparty/json11-2016-01-26)
# Build local gtest
set(gtest_force_shared_crt ON)
@ -51,18 +63,14 @@ include_directories(
)
include_directories(SYSTEM
${Boost_INCLUDE_DIRS}
thirdparty/gtest-1.7.0/include
thirdparty/json11-2016-01-26
thirdparty/jsoncpp-0.9.4/include
thirdparty/rapidjson-1.0.2/include
thirdparty/picojson-1.3.0
thirdparty/nlohmann-json-1.1.0
${Boost_INCLUDE_DIRS}
)
if(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED)
include_directories(SYSTEM
thirdparty/json11-2016-01-26
)
endif()
# Custom schema validation example
add_executable(custom_schema
@ -78,22 +86,16 @@ set(TEST_SOURCES
tests/test_adapter_comparison.cpp
tests/test_fetch_document_callback.cpp
tests/test_json_pointer.cpp
tests/test_json11_adapter.cpp
tests/test_jsoncpp_adapter.cpp
tests/test_nlohmann_json_adapter.cpp
tests/test_property_tree_adapter.cpp
tests/test_rapidjson_adapter.cpp
tests/test_picojson_adapter.cpp
tests/test_validation_errors.cpp
tests/test_validator.cpp
tests/test_poly_constraint.cpp
)
if(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED)
set(TEST_SOURCES
${TEST_SOURCES}
tests/test_json11_adapter.cpp
tests/test_nlohmann_json_adapter.cpp
)
endif()
)
# Unit tests executable
add_executable(test_suite ${TEST_SOURCES})
@ -103,10 +105,7 @@ set_target_properties(test_suite
PROPERTIES COMPILE_DEFINITIONS "PICOJSON_USE_INT64"
)
set(TEST_LIBS gtest gtest_main jsoncpp)
if(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED)
set(TEST_LIBS ${TEST_LIBS} json11)
endif()
set(TEST_LIBS gtest gtest_main jsoncpp json11)
target_link_libraries(test_suite ${TEST_LIBS} ${Boost_LIBRARIES})
target_link_libraries(custom_schema ${Boost_LIBRARIES})