2014-04-17 02:58:51 +02:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
|
|
|
project (valijson)
|
|
|
|
|
2016-03-01 07:50:25 +01:00
|
|
|
option (INSTALL_HEADERS "Install valijson Headers." TRUE)
|
|
|
|
option (BUILD_EXAMPLES "Build valijson Examples." FALSE)
|
|
|
|
option (BUILD_TESTS "Build valijson Tests." FALSE)
|
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ")
|
2015-11-19 16:55:53 +01:00
|
|
|
if (BUILD_TESTS OR BUILD_EXAMPLES)
|
2016-01-17 01:48:39 +01:00
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
|
2016-01-27 18:40:07 +01:00
|
|
|
if(VALIJSON_CXX11_ADAPTERS STREQUAL "disabled")
|
|
|
|
message(STATUS "Building with C++11 support disabled")
|
|
|
|
else()
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
|
|
|
if(COMPILER_SUPPORTS_CXX11)
|
2016-01-28 05:35:44 +01:00
|
|
|
set(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED 1)
|
2016-01-27 18:40:07 +01:00
|
|
|
message(STATUS "Building with C++11 support enabled")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DVALIJSON_BUILD_CXX11_ADAPTERS=1")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-10-23 02:37:38 +02:00
|
|
|
|
2015-10-16 23:27:39 +02:00
|
|
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
2014-04-17 02:58:51 +02:00
|
|
|
set(Boost_USE_STATIC_LIBS OFF)
|
|
|
|
set(Boost_USE_MULTITHREADED ON)
|
|
|
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
|
|
|
|
2014-04-17 23:31:18 +02:00
|
|
|
find_package(Boost 1.55.0 COMPONENTS regex REQUIRED)
|
2014-04-17 02:58:51 +02:00
|
|
|
|
|
|
|
# jsoncpp library
|
|
|
|
add_library(jsoncpp
|
2015-03-15 02:24:34 +01:00
|
|
|
thirdparty/jsoncpp-0.9.4/src/lib_json/json_reader.cpp
|
|
|
|
thirdparty/jsoncpp-0.9.4/src/lib_json/json_value.cpp
|
|
|
|
thirdparty/jsoncpp-0.9.4/src/lib_json/json_writer.cpp
|
2014-04-17 02:58:51 +02:00
|
|
|
)
|
|
|
|
|
2016-01-28 05:35:44 +01:00
|
|
|
if(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED)
|
|
|
|
add_library(json11
|
|
|
|
thirdparty/json11-2016-01-26/json11.cpp
|
|
|
|
)
|
|
|
|
endif()
|
2016-01-26 05:19:40 +01:00
|
|
|
|
2014-04-17 02:58:51 +02:00
|
|
|
# Build local gtest
|
2015-10-16 23:27:39 +02:00
|
|
|
set(gtest_force_shared_crt ON)
|
2014-04-17 02:58:51 +02:00
|
|
|
add_subdirectory(thirdparty/gtest-1.7.0)
|
|
|
|
|
|
|
|
# Include path
|
2015-02-04 13:59:48 +01:00
|
|
|
include_directories(
|
|
|
|
include
|
2016-04-06 15:31:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
include_directories(SYSTEM
|
|
|
|
${Boost_INCLUDE_DIRS}
|
2015-02-04 13:59:48 +01:00
|
|
|
thirdparty/gtest-1.7.0/include
|
2015-03-15 02:24:34 +01:00
|
|
|
thirdparty/jsoncpp-0.9.4/include
|
2016-01-17 01:43:40 +01:00
|
|
|
thirdparty/rapidjson-1.0.2/include
|
2015-05-08 17:24:29 +02:00
|
|
|
thirdparty/picojson-1.3.0
|
2016-02-02 10:51:45 +01:00
|
|
|
thirdparty/nlohmann-json-1.1.0
|
2015-02-04 13:59:48 +01:00
|
|
|
)
|
2016-01-28 05:35:44 +01:00
|
|
|
if(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED)
|
2016-04-06 15:31:06 +02:00
|
|
|
include_directories(SYSTEM
|
2016-01-28 05:35:44 +01:00
|
|
|
thirdparty/json11-2016-01-26
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-03-15 05:38:40 +01:00
|
|
|
# Custom schema validation example
|
|
|
|
add_executable(custom_schema
|
|
|
|
examples/custom_schema.cpp
|
|
|
|
)
|
|
|
|
|
2014-06-15 07:24:26 +02:00
|
|
|
# External schema validation example
|
|
|
|
add_executable(external_schema
|
|
|
|
examples/external_schema.cpp
|
|
|
|
)
|
|
|
|
|
2016-01-28 05:35:44 +01:00
|
|
|
set(TEST_SOURCES
|
2014-04-17 02:58:51 +02:00
|
|
|
tests/test_adapter_comparison.cpp
|
2015-05-04 03:03:59 +02:00
|
|
|
tests/test_fetch_document_callback.cpp
|
2015-05-06 10:46:39 +02:00
|
|
|
tests/test_json_pointer.cpp
|
2014-04-17 02:58:51 +02:00
|
|
|
tests/test_jsoncpp_adapter.cpp
|
|
|
|
tests/test_property_tree_adapter.cpp
|
|
|
|
tests/test_rapidjson_adapter.cpp
|
2015-05-08 17:24:29 +02:00
|
|
|
tests/test_picojson_adapter.cpp
|
2014-04-17 02:58:51 +02:00
|
|
|
tests/test_validation_errors.cpp
|
|
|
|
tests/test_validator.cpp
|
2016-04-06 15:31:06 +02:00
|
|
|
tests/test_poly_constraint.cpp
|
2016-01-28 05:35:44 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
if(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED)
|
|
|
|
set(TEST_SOURCES
|
|
|
|
${TEST_SOURCES}
|
|
|
|
tests/test_json11_adapter.cpp
|
2016-02-02 11:08:59 +01:00
|
|
|
tests/test_nlohmann_json_adapter.cpp
|
2016-01-28 05:35:44 +01:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Unit tests executable
|
|
|
|
add_executable(test_suite ${TEST_SOURCES})
|
2014-04-17 02:58:51 +02:00
|
|
|
|
2015-05-08 17:24:29 +02:00
|
|
|
# Definition for using picojson
|
|
|
|
set_target_properties(test_suite
|
|
|
|
PROPERTIES COMPILE_DEFINITIONS "PICOJSON_USE_INT64"
|
|
|
|
)
|
|
|
|
|
2016-01-28 05:35:44 +01:00
|
|
|
set(TEST_LIBS gtest gtest_main jsoncpp)
|
|
|
|
if(VALIJSON_CXX11_ADAPTERS_ARE_ENABLED)
|
|
|
|
set(TEST_LIBS ${TEST_LIBS} json11)
|
|
|
|
endif()
|
2014-04-17 02:58:51 +02:00
|
|
|
|
|
|
|
target_link_libraries(test_suite ${TEST_LIBS} ${Boost_LIBRARIES})
|
2015-03-15 05:38:40 +01:00
|
|
|
target_link_libraries(custom_schema ${Boost_LIBRARIES})
|
2014-06-15 07:24:26 +02:00
|
|
|
target_link_libraries(external_schema ${Boost_LIBRARIES})
|
2015-11-19 16:55:53 +01:00
|
|
|
endif()
|
|
|
|
if (INSTALL_HEADERS )
|
|
|
|
install(DIRECTORY include/ DESTINATION include )
|
|
|
|
endif()
|
2015-03-15 05:38:40 +01:00
|
|
|
|