1
- cmake_minimum_required (VERSION 3.1)
2
- project (valijson)
1
+ cmake_minimum_required (VERSION 3.1)
2
+ project (valijson)
3
3
4
4
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR} /cmake" )
5
5
@@ -27,12 +27,7 @@ else()
27
27
message (FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler." )
28
28
endif ()
29
29
30
- add_definitions (-DBOOST_ALL_DYN_LINK)
31
- set (Boost_USE_STATIC_LIBS OFF )
32
- set (Boost_USE_MULTITHREADED ON )
33
- set (Boost_USE_STATIC_RUNTIME OFF )
34
-
35
- find_package (Boost 1.54.0 REQUIRED)
30
+ find_package (curlpp)
36
31
find_package (Poco OPTIONAL_COMPONENTS JSON)
37
32
find_package (Qt5Core)
38
33
@@ -53,13 +48,8 @@ add_library(json11
53
48
target_include_directories (json11 SYSTEM PRIVATE thirdparty/json11-ec4e452)
54
49
set_target_properties (json11 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /thirdparty/json11-ec4e452)
55
50
56
- # Build local gtest
57
- set (gtest_force_shared_crt ON )
58
- add_subdirectory (thirdparty/gtest-1.7.0)
59
-
60
- # Include path
61
- include_directories (include )
62
- include_directories (SYSTEM
51
+ # Not all of these are required for examples build it doesn't hurt to include them
52
+ include_directories (include SYSTEM
63
53
thirdparty/gtest-1.7.0/include
64
54
thirdparty/json11-ec4e452
65
55
thirdparty/jsoncpp-0.9.4/include
@@ -68,81 +58,103 @@ include_directories(SYSTEM
68
58
thirdparty/nlohmann-json-3.1.2
69
59
${Boost_INCLUDE_DIRS}
70
60
${Qt5Core_INCLUDE_DIRS}
71
- )
72
-
73
- # Custom schema validation example
74
- add_executable (custom_schema
75
- examples/custom_schema.cpp
76
- )
77
-
78
- # External schema validation example
79
- add_executable (external_schema
80
- examples/external_schema.cpp
81
- )
82
-
83
- add_executable (array_iteration_basics
84
- examples/array_iteration_basics.cpp
85
- )
61
+ )
62
+
63
+ if (valijson_BUILD_TESTS)
64
+ find_package (Boost 1.54.0 REQUIRED)
65
+ if (Boost_FOUND)
66
+ add_definitions (-DBOOST_ALL_DYN_LINK)
67
+ set (Boost_USE_STATIC_LIBS OFF )
68
+ set (Boost_USE_MULTITHREADED ON )
69
+ set (Boost_USE_STATIC_RUNTIME OFF )
70
+ endif ()
71
+
72
+ # Build local gtest
73
+ set (gtest_force_shared_crt ON )
74
+ add_subdirectory (thirdparty/gtest-1.7.0)
75
+
76
+ set (TEST_SOURCES
77
+ tests/test_adapter_comparison.cpp
78
+ tests/test_fetch_document_callback.cpp
79
+ tests/test_json_pointer.cpp
80
+ tests/test_json11_adapter.cpp
81
+ tests/test_jsoncpp_adapter.cpp
82
+ tests/test_nlohmann_json_adapter.cpp
83
+ tests/test_property_tree_adapter.cpp
84
+ tests/test_rapidjson_adapter.cpp
85
+ tests/test_picojson_adapter.cpp
86
+ tests/test_poco_json_adapter.cpp
87
+ tests/test_poly_constraint.cpp
88
+ tests/test_validation_errors.cpp
89
+ tests/test_validator.cpp
90
+ )
91
+
92
+ if (Qt5Core_FOUND)
93
+ list (APPEND TEST_SOURCES tests/test_qtjson_adapter.cpp)
94
+ endif ()
95
+
96
+ # Unit tests executable
97
+ add_executable (test_suite ${TEST_SOURCES} )
98
+
99
+ # Definition for using picojson
100
+ set_target_properties (test_suite PROPERTIES COMPILE_DEFINITIONS "PICOJSON_USE_INT64" )
101
+
102
+ set (TEST_LIBS gtest gtest_main jsoncpp json11)
103
+
104
+ if (Qt5Core_FOUND)
105
+ list (APPEND TEST_LIBS Qt5::Core)
106
+ target_compile_definitions (test_suite PRIVATE "VALIJSON_BUILD_QT_ADAPTERS" )
107
+ endif ()
108
+
109
+ if (Poco_FOUND)
110
+ list (APPEND TEST_LIBS ${Poco_Foundation_LIBRARIES} ${Poco_JSON_LIBRARIES} )
111
+ target_compile_definitions (test_suite PRIVATE "VALIJSON_BUILD_POCO_ADAPTERS" )
112
+ endif ()
113
+
114
+ target_link_libraries (test_suite ${TEST_LIBS} ${Boost_LIBRARIES} )
115
+ endif ()
86
116
87
- add_executable (array_iteration_template_fn
88
- examples/array_iteration_template_fn.cpp
89
- )
117
+ if (valijson_BUILD_EXAMPLES)
118
+ include_directories (SYSTEM )
90
119
91
- add_executable (object_iteration
92
- examples/object_iteration .cpp
93
- )
120
+ add_executable (custom_schema
121
+ examples/custom_schema .cpp
122
+ )
94
123
95
- add_executable (json_pointers
96
- examples/json_pointers .cpp
97
- )
124
+ add_executable (external_schema
125
+ examples/external_schema .cpp
126
+ )
98
127
99
- add_executable (remote_resolution
100
- examples/remote_resolution .cpp
101
- )
128
+ add_executable (array_iteration_basics
129
+ examples/array_iteration_basics .cpp
130
+ )
102
131
103
- set (TEST_SOURCES
104
- tests/test_adapter_comparison.cpp
105
- tests/test_fetch_document_callback.cpp
106
- tests/test_json_pointer.cpp
107
- tests/test_json11_adapter.cpp
108
- tests/test_jsoncpp_adapter.cpp
109
- tests/test_nlohmann_json_adapter.cpp
110
- tests/test_property_tree_adapter.cpp
111
- tests/test_rapidjson_adapter.cpp
112
- tests/test_picojson_adapter.cpp
113
- tests/test_poco_json_adapter.cpp
114
- tests/test_validation_errors.cpp
115
- tests/test_validator.cpp
116
- tests/test_poly_constraint.cpp
117
- )
132
+ add_executable (array_iteration_template_fn
133
+ examples/array_iteration_template_fn.cpp
134
+ )
118
135
119
- if (Qt5Core_FOUND)
120
- list ( APPEND TEST_SOURCES tests/test_qtjson_adapter .cpp)
121
- endif ( )
136
+ add_executable (object_iteration
137
+ examples/object_iteration .cpp
138
+ )
122
139
123
- # Unit tests executable
124
- add_executable (test_suite ${TEST_SOURCES} )
140
+ add_executable (json_pointers
141
+ examples/json_pointers.cpp
142
+ )
125
143
126
- # Definition for using picojson
127
- set_target_properties (test_suite PROPERTIES COMPILE_DEFINITIONS "PICOJSON_USE_INT64" )
144
+ if (curlpp_FOUND)
145
+ include_directories ( ${curlpp_INCLUDE_DIR} )
128
146
129
- set (TEST_LIBS gtest gtest_main jsoncpp json11)
147
+ add_executable (remote_resolution
148
+ examples/remote_resolution.cpp
149
+ )
130
150
131
- if (Qt5Core_FOUND)
132
- list (APPEND TEST_LIBS Qt5::Core)
133
- target_compile_definitions (test_suite PRIVATE "VALIJSON_BUILD_QT_ADAPTERS" )
134
- endif ()
151
+ target_link_libraries (remote_resolution curl ${curlpp_LIBRARIES} )
152
+ endif ()
135
153
136
- if (Poco_FOUND)
137
- list (APPEND TEST_LIBS ${Poco_Foundation_LIBRARIES} ${Poco_JSON_LIBRARIES} )
138
- target_compile_definitions (test_suite PRIVATE "VALIJSON_BUILD_POCO_ADAPTERS" )
154
+ target_link_libraries (custom_schema ${Boost_LIBRARIES} )
155
+ target_link_libraries (external_schema ${Boost_LIBRARIES} )
156
+ target_link_libraries (array_iteration_basics jsoncpp)
157
+ target_link_libraries (array_iteration_template_fn jsoncpp)
158
+ target_link_libraries (object_iteration jsoncpp)
159
+ target_link_libraries (json_pointers)
139
160
endif ()
140
-
141
- target_link_libraries (test_suite ${TEST_LIBS} ${Boost_LIBRARIES} )
142
- target_link_libraries (custom_schema ${Boost_LIBRARIES} )
143
- target_link_libraries (external_schema ${Boost_LIBRARIES} )
144
- target_link_libraries (array_iteration_basics jsoncpp)
145
- target_link_libraries (array_iteration_template_fn jsoncpp)
146
- target_link_libraries (object_iteration jsoncpp)
147
- target_link_libraries (json_pointers)
148
- target_link_libraries (remote_resolution curl curlpp)
0 commit comments