]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # CMake build control file for Serialization Library tests |
2 | ||
3 | cmake_minimum_required(VERSION 3.0) | |
4 | ||
5 | if (POLICY CMP0054) | |
6 | cmake_policy (SET CMP0054 NEW) | |
7 | endif (POLICY CMP0054) | |
8 | ||
9 | if (POLICY CMP0063) | |
10 | cmake_policy (SET CMP0063 NEW) | |
11 | endif (POLICY CMP0063) | |
12 | ||
13 | if(Boost_USE_STATIC_LIBS) | |
14 | project("Serialization-Static") | |
15 | else() | |
16 | project("Serialization-Shared") | |
17 | endif() | |
18 | ||
19 | # | |
20 | # Compiler settings | |
21 | # | |
22 | ||
23 | message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" ) | |
b32b8144 | 24 | add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) |
7c673cae FG |
25 | |
26 | if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) | |
27 | add_definitions( -ftemplate-depth=300 ) | |
28 | # we use gcc to test for C++03 compatibility | |
b32b8144 | 29 | add_definitions( -std=c++03 ) |
7c673cae FG |
30 | message(STATUS "compiler is g++ c++03") |
31 | set(COMPILER_SUPPORTS_CXX11 FALSE) | |
32 | elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" ) | |
33 | add_definitions( /wd4996 ) | |
34 | message(STATUS "compiler is MSVC") | |
35 | set(COMPILER_SUPPORTS_CXX11 TRUE) | |
36 | elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) | |
37 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=300") | |
38 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98") | |
39 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
40 | set(CMAKE_CXX_FLAGS_DEBUG "-g -O0" ) | |
41 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" ) | |
42 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -dead_strip") | |
43 | set(COMPILER_SUPPORTS_CXX11 TRUE) | |
44 | endif() | |
45 | ||
46 | # | |
47 | # IDE settings | |
48 | # | |
49 | ||
50 | if( CMAKE_HOST_APPLE ) | |
51 | # note: it seems that bjam builds both address models in any case | |
52 | # so we can defer this decision to the IDE just as we do for debug/release | |
53 | # so we'll not use this now | |
54 | # set(Boost_ADDRESS_MODEL 64 CACHE INTEGER "32/64 bits") | |
55 | set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Link to Boost static libraries") | |
56 | set(Boost_USE_MULTITHREADED ON) | |
57 | else() | |
58 | set(Boost_ADDRESS_MODEL 64 CACHE INTEGER "32/64 bits") | |
59 | set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Link to Boost static libraries") | |
60 | set(Boost_USE_MULTITHREADED ON) | |
61 | endif() | |
62 | ||
63 | # | |
64 | # Locate Project Prerequisites | |
65 | # | |
66 | ||
67 | # Boost | |
68 | ||
69 | # note: we're assuming that boost has been built with: | |
70 | # ./b2 —-layout=versioned toolset=clang-darwin link=static,shared variant=debug,release stage | |
71 | ||
72 | ########################### | |
73 | # special notes for Xcode. | |
74 | ||
75 | # these three should result in CMake setting the variables | |
76 | # Boost_SERIALIZATION_LIBRARY_DEBUG … to the correct values. | |
77 | ||
78 | # But my current version of CMake doesn't automatically set the library names | |
79 | # to point to the the libraries to be used. The variables are created | |
80 | # but they are not initialized. So be prepared to set these variables by hand. | |
81 | # If you want to use the static libraries - point to the boost libraries ending | |
82 | # in ".a". If you want to use the shared boost libraries - point to the libraries | |
83 | # ending in ".dylib". | |
84 | ||
85 | # But wait - there's more. | |
86 | # if both lib.a and lib.dylib both exist in the library directory, Xcode will | |
87 | # automatically chose the *.dylib one - and there's nothing you can do to fix this. | |
88 | # So my recommendation is | |
89 | # a) to place the compiled libraries in two different directories | |
90 | # - e.g. stage/lib-static/*.a and stage/lib-shared/*.dylib | |
91 | # and set the CMake variable Boost_LIBRARY_DIR to point to one or the other | |
92 | # b) create two different CMake build directories - build-static and build-shared | |
93 | # and switch between projects as desired. I like to test both since | |
94 | # there are things like dead code elimination and visibility which vary | |
95 | # between the two environments. | |
96 | # | |
97 | # caveat - as I write this, I've been unable to get the tests on the shared | |
98 | # library to function. Problem is that one needs to either put the shared | |
99 | # libraries in a special known place or set an environmental | |
100 | # variable which points to the shared library directory. I prefer the latter | |
101 | # but I've been unable to figure out how to get Xcode to do on a global basis | |
102 | # and it's not practical to do this for 247 test targets one at a time. | |
103 | ||
104 | # c) The targets in the project will by default be built as universal 32/64 binaries | |
105 | # I have yet to experiment with these yet so I just set the target to 64 bit. | |
106 | ||
107 | # end special note for Xcode | |
108 | ############################ | |
109 | ||
b32b8144 FG |
110 | set(Boost_DEBUG true) |
111 | set(Boost_DETAILED_FAILURE_MSG true) | |
112 | set(Boost_FOUND true) | |
113 | ||
7c673cae | 114 | find_package(Boost REQUIRED COMPONENTS system filesystem) |
b32b8144 FG |
115 | include(CheckIncludeFileCXX) |
116 | ||
117 | message(STATUS "Boost_FOUND is ${Boost_FOUND}") | |
7c673cae FG |
118 | |
119 | if(Boost_FOUND) | |
b32b8144 | 120 | message(STATUS "Boost Found!") |
7c673cae FG |
121 | message(STATUS "Boost is ${BOOST_ROOT}") |
122 | message(STATUS "Boost directories found at ${Boost_INCLUDE_DIRS}") | |
123 | message(STATUS "Boost libraries found at ${Boost_LIBRARY_DIRS}") | |
b32b8144 | 124 | message(STATUS "Boost libraries prefix is ${Boost_LIB_PREFIX}") |
7c673cae FG |
125 | message(STATUS "Boost component libraries to be linked are ${Boost_LIBRARIES}") |
126 | message(STATUS "Boost version found is ${Boost_VERSION}") | |
b32b8144 FG |
127 | #include_directories("../include" "${Boost_INCLUDE_DIRS}") |
128 | #link_directories("${Boost_LIBRARY_DIRS}") | |
129 | else() | |
130 | message(STATUS "Boost NOT Found!") | |
7c673cae FG |
131 | endif() |
132 | ||
133 | if(Boost_USE_STATIC_LIBS) | |
b32b8144 | 134 | message(STATUS "Use static libraries") |
7c673cae FG |
135 | set(LINK_TYPE "STATIC") |
136 | else() | |
137 | message(STATUS "Building shared libraries") | |
138 | set(LINK_TYPE "SHARED") | |
139 | add_definitions( "-DBOOST_ALL_DYN_LINK=1") | |
140 | add_definitions( "-DBOOST_ALL_NO_LIB=1") | |
141 | add_definitions( "-DBOOST_LIB_DIAGNOSTICS=1") | |
b32b8144 FG |
142 | set(CMAKE_CXX_VISIBILITY_PRESET hidden) |
143 | set(VISIBILITY_INLINES_HIDDEN) | |
7c673cae | 144 | endif() |
7c673cae FG |
145 | |
146 | ########################### | |
147 | # library builds | |
148 | ||
149 | add_library(serialization ${LINK_TYPE} | |
150 | ../src/archive_exception.cpp | |
151 | ../src/basic_archive.cpp | |
152 | ../src/basic_iarchive.cpp | |
153 | ../src/basic_iserializer.cpp | |
154 | ../src/basic_oarchive.cpp | |
155 | ../src/basic_oserializer.cpp | |
156 | ../src/basic_pointer_iserializer.cpp | |
157 | ../src/basic_pointer_oserializer.cpp | |
158 | ../src/basic_serializer_map.cpp | |
159 | ../src/basic_text_iprimitive.cpp | |
160 | ../src/basic_text_oprimitive.cpp | |
161 | ../src/basic_xml_archive.cpp | |
162 | ../src/binary_iarchive.cpp | |
163 | ../src/binary_oarchive.cpp | |
164 | ../src/extended_type_info_no_rtti.cpp | |
165 | ../src/extended_type_info_typeid.cpp | |
166 | ../src/extended_type_info.cpp | |
167 | ../src/polymorphic_iarchive.cpp | |
168 | ../src/polymorphic_oarchive.cpp | |
7c673cae FG |
169 | ../src/stl_port.cpp |
170 | ../src/text_iarchive.cpp | |
171 | ../src/text_oarchive.cpp | |
172 | ../src/void_cast.cpp | |
173 | ../src/xml_archive_exception.cpp | |
174 | ../src/xml_iarchive.cpp | |
175 | ../src/xml_oarchive.cpp | |
176 | ../src/xml_grammar.cpp | |
177 | ../src/utf8_codecvt_facet.cpp | |
178 | ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"' | |
179 | ) | |
180 | ||
7c673cae FG |
181 | add_library(wserialization ${LINK_TYPE} |
182 | ../src/codecvt_null.cpp | |
183 | ../src/basic_text_wiprimitive.cpp | |
184 | ../src/basic_text_woprimitive.cpp | |
185 | ../src/text_wiarchive.cpp | |
186 | ../src/text_woarchive.cpp | |
187 | ../src/xml_wiarchive.cpp | |
188 | ../src/xml_woarchive.cpp | |
189 | ../src/xml_wgrammar.cpp | |
190 | ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"' | |
191 | ) | |
192 | ||
7c673cae FG |
193 | # end library build |
194 | ########################### | |
195 | ||
196 | ########################### | |
197 | # test targets | |
198 | ||
199 | function( serialization_test test_name) | |
200 | set(arglist) | |
201 | foreach(a IN ITEMS ${ARGN} ) | |
202 | set(arglist ${arglist} ../test/${a}.cpp) | |
203 | endforeach() | |
204 | message(STATUS ${test_name}) | |
205 | add_executable( ${test_name} ../test/${test_name}.cpp ${arglist} ) | |
206 | target_link_libraries(${test_name} serialization wserialization ${Boost_LIBRARIES}) | |
207 | add_test( ${test_name} ${test_name} ) | |
208 | endfunction(serialization_test) | |
209 | ||
210 | function(archive_test test_name) | |
211 | set(arglist) | |
212 | foreach(a IN ITEMS ${ARGN} ) | |
213 | set(arglist ${arglist} ../test/${a}.cpp) | |
214 | endforeach() | |
215 | foreach( | |
216 | archive-name | |
217 | IN ITEMS text_archive text_warchive binary_archive xml_archive xml_warchive | |
218 | ) | |
219 | set(amended_test_name ${test_name}_${archive-name}) | |
220 | message(STATUS ${amended_test_name}) | |
221 | add_executable(${amended_test_name} ../test/${test_name}.cpp ${arglist}) | |
222 | set_property( | |
223 | TARGET ${amended_test_name} | |
224 | PROPERTY COMPILE_DEFINITIONS BOOST_ARCHIVE_TEST=${archive-name}.hpp | |
225 | ) | |
226 | target_link_libraries(${amended_test_name} serialization wserialization ${Boost_LIBRARIES}) | |
227 | add_test(${amended_test_name} ${amended_test_name}) | |
228 | endforeach() | |
229 | endfunction(archive_test) | |
230 | ||
231 | function(polymorphic_archive_test test_name) | |
232 | set(arglist) | |
233 | foreach(a IN ITEMS ${ARGN} ) | |
234 | set(arglist ${arglist} ../test/${a}.cpp) | |
235 | endforeach() | |
236 | foreach( | |
237 | archive-name | |
238 | IN ITEMS text_archive text_warchive binary_archive xml_archive xml_warchive | |
239 | ) | |
240 | set(amended_test_name ${test_name}_polymorphic_${archive-name}) | |
241 | message(STATUS ${amended_test_name}) | |
242 | add_executable(${amended_test_name} ../test/${test_name}.cpp ${arglist}) | |
243 | set_property( | |
244 | TARGET ${amended_test_name} | |
245 | PROPERTY COMPILE_DEFINITIONS BOOST_ARCHIVE_TEST=polymorphic_${archive-name}.hpp | |
246 | ) | |
247 | target_link_libraries(${amended_test_name} serialization wserialization ${Boost_LIBRARIES}) | |
248 | add_test(${amended_test_name} ${amended_test_name}) | |
249 | endforeach() | |
250 | endfunction(polymorphic_archive_test) | |
251 | ||
252 | enable_testing() | |
253 | ||
b32b8144 FG |
254 | serialization_test(test_dll_exported polymorphic_derived2 polymorphic_base) |
255 | ||
7c673cae FG |
256 | # serialization(test_dll_simple dll_a_lib) |
257 | # compile test_dll_plugin.cpp | |
258 | # Running the following test requires that the test know the directory | |
259 | # in which the dll is stored. I don't know how to extract this from bjam | |
260 | # serialization(test_dll_plugin : : dll_polymorphic_derived2_lib) | |
261 | ||
262 | serialization_test(test_private_ctor) | |
263 | serialization_test(test_reset_object_address A) | |
264 | serialization_test(test_void_cast) | |
265 | serialization_test(test_mult_archive_types) | |
266 | serialization_test(test_iterators) | |
267 | serialization_test(test_iterators_base64) | |
268 | serialization_test(test_inclusion) | |
b32b8144 | 269 | serialization_test(test_inclusion2) |
7c673cae | 270 | serialization_test(test_smart_cast) |
7c673cae | 271 | serialization_test(test_codecvt_null ../src/codecvt_null) |
b32b8144 | 272 | serialization_test(test_strong_typedef) |
7c673cae FG |
273 | |
274 | archive_test(test_native_array A) | |
275 | archive_test(test_boost_array A) | |
276 | if(COMPILER_SUPPORTS_CXX11) | |
277 | archive_test(test_array A) | |
278 | endif() | |
279 | archive_test(test_binary) | |
280 | archive_test(test_bitset) | |
281 | archive_test(test_class_info_save) | |
282 | archive_test(test_class_info_load) | |
283 | archive_test(test_complex) | |
284 | archive_test(test_contained_class A) | |
285 | archive_test(test_cyclic_ptrs A) | |
286 | archive_test(test_delete_pointer) | |
287 | archive_test(test_deque A) | |
288 | archive_test(test_derived) | |
289 | archive_test(test_derived_class A) | |
290 | archive_test(test_diamond) | |
291 | archive_test(test_diamond_complex) | |
292 | archive_test(test_exported polymorphic_base) | |
293 | archive_test(test_forward_list A) | |
294 | archive_test(test_forward_list_ptrs A) | |
295 | archive_test(test_helper_support) | |
296 | archive_test(test_interrupts) | |
297 | archive_test(test_list A) | |
298 | archive_test(test_list_ptrs A) | |
299 | archive_test(test_map A) | |
300 | archive_test(test_map_boost_unordered A) | |
301 | archive_test(test_mi) | |
302 | archive_test(test_multiple_ptrs A) | |
303 | archive_test(test_multiple_inheritance) | |
304 | archive_test(test_no_rtti polymorphic_base polymorphic_derived1) | |
305 | archive_test(test_new_operator A) | |
306 | archive_test(test_non_intrusive) | |
307 | archive_test(test_non_default_ctor) | |
308 | archive_test(test_non_default_ctor2) | |
309 | archive_test(test_null_ptr) | |
310 | archive_test(test_nvp A) | |
311 | archive_test(test_object) | |
312 | archive_test(test_optional) | |
313 | archive_test(test_primitive) | |
314 | archive_test(test_priority_queue A) | |
315 | archive_test(test_private_base) | |
316 | archive_test(test_private_base2) | |
317 | archive_test(test_queue A) | |
318 | archive_test(test_recursion A) | |
319 | archive_test(test_registered) | |
320 | archive_test(test_shared_ptr) | |
321 | archive_test(test_shared_ptr_multi_base) | |
322 | archive_test(test_shared_ptr_132) | |
323 | archive_test(test_simple_class A) | |
324 | archive_test(test_simple_class_ptr A) | |
b32b8144 FG |
325 | CHECK_INCLUDE_FILE_CXX(slist SLIST_FOUND) |
326 | if(SLIST_FOUND) | |
327 | message(STATUS "slist header found") | |
328 | archive_test(test_slist A) | |
329 | archive_test(test_slist_ptr A) | |
330 | else() | |
331 | message(STATUS "slist header NOT found") | |
332 | endif() | |
7c673cae FG |
333 | archive_test(test_stack A) |
334 | archive_test(test_split) | |
335 | archive_test(test_tracking) | |
336 | archive_test(test_unregistered) | |
337 | archive_test(test_unique_ptr) | |
338 | archive_test(test_valarray) | |
339 | archive_test(test_variant A) | |
340 | archive_test(test_vector A) | |
341 | archive_test(test_set A) | |
342 | archive_test(test_set_boost_unordered A) | |
343 | if(COMPILER_SUPPORTS_CXX11) | |
344 | archive_test(test_set_unordered A) | |
b32b8144 FG |
345 | else() |
346 | CHECK_INCLUDE_FILE_CXX(hash_set HASH_SET_FOUND) | |
347 | if(HASH_SET_FOUND) | |
348 | archive_test(test_set_hashed A) | |
349 | endif() | |
7c673cae FG |
350 | endif() |
351 | if(COMPILER_SUPPORTS_CXX11) | |
352 | archive_test(test_map_unordered A) | |
b32b8144 FG |
353 | else() |
354 | CHECK_INCLUDE_FILE_CXX(hash_map HASH_MAP_FOUND) | |
355 | if(HASH_MAP_FOUND) | |
356 | archive_test(test_map_hashed A) | |
357 | endif() | |
7c673cae FG |
358 | endif() |
359 | ||
360 | polymorphic_archive_test(test_polymorphic test_polymorphic_A A) | |
361 | polymorphic_archive_test(test_polymorphic2 test_polymorphic2imp) | |
362 | polymorphic_archive_test(test_polymorphic_helper) | |
363 | ||
364 | # end test targets | |
365 | #################### | |
366 | ||
367 | #################### | |
368 | # add headers in IDE | |
369 | ||
370 | # for serialisation | |
371 | ||
372 | file(GLOB x | |
373 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" | |
374 | "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/*.hpp" | |
375 | ) | |
376 | add_custom_target(archive SOURCES ${x}) | |
377 | set_property(TARGET archive PROPERTY FOLDER "serialization") | |
378 | ||
379 | file(GLOB x | |
380 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" | |
381 | "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/detail/*.hpp" | |
382 | ) | |
383 | add_custom_target(archive-detail SOURCES ${x}) | |
384 | set_property(TARGET archive-detail PROPERTY FOLDER "serialization") | |
385 | ||
386 | file(GLOB x | |
387 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" | |
388 | "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/impl/*.ipp" | |
389 | ) | |
390 | add_custom_target(archive-impl SOURCES ${x}) | |
391 | set_property(TARGET archive-impl PROPERTY FOLDER "serialization") | |
392 | ||
393 | file(GLOB x | |
394 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" | |
395 | "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/iterators/*.hpp" | |
396 | ) | |
397 | add_custom_target(archive-iterators SOURCES ${x}) | |
398 | set_property(TARGET archive-iterators PROPERTY FOLDER "serialization") | |
399 | ||
400 | file(GLOB x | |
401 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" | |
402 | "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/serialization/*.hpp" | |
403 | ) | |
404 | add_custom_target(serialization-headers SOURCES ${x}) | |
405 | set_property(TARGET serialization-headers PROPERTY FOLDER "serialization") | |
406 | ||
407 | file(GLOB x | |
408 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" | |
409 | "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/serialization/detail/*.hpp" | |
410 | ) | |
411 | add_custom_target(serialization-detail SOURCES ${x}) | |
412 | set_property(TARGET serialization-detail PROPERTY FOLDER "serialization") | |
413 | ||
414 | # for wserialization | |
415 | ||
416 | file(GLOB x | |
417 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" | |
418 | "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/*_w*.hpp" | |
419 | ) | |
420 | add_custom_target(wserialization_headers SOURCES ${x}) | |
421 | set_property(TARGET wserialization_headers PROPERTY FOLDER "wserialization") | |
422 | ||
423 | # end headers in IDE | |
424 | #################### | |
425 | ||
426 | ##################### | |
427 | # add test project to run misc tests | |
428 | ||
429 | add_executable( test_z ../test/test_z.cpp) | |
430 | target_link_libraries(test_z serialization wserialization ${Boost_LIBRARIES}) | |
431 | ||
432 | # end test project | |
433 | ##################### |