]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/serialization/CMake/CMakeLists.txt
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / serialization / CMake / CMakeLists.txt
CommitLineData
7c673cae
FG
1# CMake build control file for Serialization Library tests
2
3cmake_minimum_required(VERSION 3.0)
4
5if (POLICY CMP0054)
6 cmake_policy (SET CMP0054 NEW)
7endif (POLICY CMP0054)
8
9if (POLICY CMP0063)
10 cmake_policy (SET CMP0063 NEW)
11endif (POLICY CMP0063)
12
13if(Boost_USE_STATIC_LIBS)
14 project("Serialization-Static")
15else()
16 project("Serialization-Shared")
17endif()
18
19#
20# Compiler settings
21#
22
23message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" )
b32b8144 24add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
7c673cae
FG
25
26if( 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)
32elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
33 add_definitions( /wd4996 )
34 message(STATUS "compiler is MSVC")
35 set(COMPILER_SUPPORTS_CXX11 TRUE)
36elseif( 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)
44endif()
45
46#
47# IDE settings
48#
49
50if( 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)
57else()
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)
61endif()
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
110set(Boost_DEBUG true)
111set(Boost_DETAILED_FAILURE_MSG true)
112set(Boost_FOUND true)
113
7c673cae 114find_package(Boost REQUIRED COMPONENTS system filesystem)
b32b8144
FG
115include(CheckIncludeFileCXX)
116
117message(STATUS "Boost_FOUND is ${Boost_FOUND}")
7c673cae
FG
118
119if(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}")
129else()
130 message(STATUS "Boost NOT Found!")
7c673cae
FG
131endif()
132
133if(Boost_USE_STATIC_LIBS)
b32b8144 134 message(STATUS "Use static libraries")
7c673cae
FG
135 set(LINK_TYPE "STATIC")
136else()
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 144endif()
7c673cae
FG
145
146###########################
147# library builds
148
149add_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
181add_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
199function( 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} )
208endfunction(serialization_test)
209
210function(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()
229endfunction(archive_test)
230
231function(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()
250endfunction(polymorphic_archive_test)
251
252enable_testing()
253
b32b8144
FG
254serialization_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
262serialization_test(test_private_ctor)
263serialization_test(test_reset_object_address A)
264serialization_test(test_void_cast)
265serialization_test(test_mult_archive_types)
266serialization_test(test_iterators)
267serialization_test(test_iterators_base64)
268serialization_test(test_inclusion)
b32b8144 269serialization_test(test_inclusion2)
7c673cae 270serialization_test(test_smart_cast)
7c673cae 271serialization_test(test_codecvt_null ../src/codecvt_null)
b32b8144 272serialization_test(test_strong_typedef)
7c673cae
FG
273
274archive_test(test_native_array A)
275archive_test(test_boost_array A)
276if(COMPILER_SUPPORTS_CXX11)
277 archive_test(test_array A)
278endif()
279archive_test(test_binary)
280archive_test(test_bitset)
281archive_test(test_class_info_save)
282archive_test(test_class_info_load)
283archive_test(test_complex)
284archive_test(test_contained_class A)
285archive_test(test_cyclic_ptrs A)
286archive_test(test_delete_pointer)
287archive_test(test_deque A)
288archive_test(test_derived)
289archive_test(test_derived_class A)
290archive_test(test_diamond)
291archive_test(test_diamond_complex)
292archive_test(test_exported polymorphic_base)
293archive_test(test_forward_list A)
294archive_test(test_forward_list_ptrs A)
295archive_test(test_helper_support)
296archive_test(test_interrupts)
297archive_test(test_list A)
298archive_test(test_list_ptrs A)
299archive_test(test_map A)
300archive_test(test_map_boost_unordered A)
301archive_test(test_mi)
302archive_test(test_multiple_ptrs A)
303archive_test(test_multiple_inheritance)
304archive_test(test_no_rtti polymorphic_base polymorphic_derived1)
305archive_test(test_new_operator A)
306archive_test(test_non_intrusive)
307archive_test(test_non_default_ctor)
308archive_test(test_non_default_ctor2)
309archive_test(test_null_ptr)
310archive_test(test_nvp A)
311archive_test(test_object)
312archive_test(test_optional)
313archive_test(test_primitive)
314archive_test(test_priority_queue A)
315archive_test(test_private_base)
316archive_test(test_private_base2)
317archive_test(test_queue A)
318archive_test(test_recursion A)
319archive_test(test_registered)
320archive_test(test_shared_ptr)
321archive_test(test_shared_ptr_multi_base)
322archive_test(test_shared_ptr_132)
323archive_test(test_simple_class A)
324archive_test(test_simple_class_ptr A)
b32b8144
FG
325CHECK_INCLUDE_FILE_CXX(slist SLIST_FOUND)
326if(SLIST_FOUND)
327 message(STATUS "slist header found")
328 archive_test(test_slist A)
329 archive_test(test_slist_ptr A)
330else()
331 message(STATUS "slist header NOT found")
332endif()
7c673cae
FG
333archive_test(test_stack A)
334archive_test(test_split)
335archive_test(test_tracking)
336archive_test(test_unregistered)
337archive_test(test_unique_ptr)
338archive_test(test_valarray)
339archive_test(test_variant A)
340archive_test(test_vector A)
341archive_test(test_set A)
342archive_test(test_set_boost_unordered A)
343if(COMPILER_SUPPORTS_CXX11)
344 archive_test(test_set_unordered A)
b32b8144
FG
345else()
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
350endif()
351if(COMPILER_SUPPORTS_CXX11)
352 archive_test(test_map_unordered A)
b32b8144
FG
353else()
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
358endif()
359
360polymorphic_archive_test(test_polymorphic test_polymorphic_A A)
361polymorphic_archive_test(test_polymorphic2 test_polymorphic2imp)
362polymorphic_archive_test(test_polymorphic_helper)
363
364# end test targets
365####################
366
367####################
368# add headers in IDE
369
370# for serialisation
371
372file(GLOB x
373 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
374 "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/*.hpp"
375)
376add_custom_target(archive SOURCES ${x})
377set_property(TARGET archive PROPERTY FOLDER "serialization")
378
379file(GLOB x
380 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
381 "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/detail/*.hpp"
382)
383add_custom_target(archive-detail SOURCES ${x})
384set_property(TARGET archive-detail PROPERTY FOLDER "serialization")
385
386file(GLOB x
387 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
388 "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/impl/*.ipp"
389)
390add_custom_target(archive-impl SOURCES ${x})
391set_property(TARGET archive-impl PROPERTY FOLDER "serialization")
392
393file(GLOB x
394 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
395 "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/iterators/*.hpp"
396)
397add_custom_target(archive-iterators SOURCES ${x})
398set_property(TARGET archive-iterators PROPERTY FOLDER "serialization")
399
400file(GLOB x
401 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
402 "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/serialization/*.hpp"
403)
404add_custom_target(serialization-headers SOURCES ${x})
405set_property(TARGET serialization-headers PROPERTY FOLDER "serialization")
406
407file(GLOB x
408 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
409 "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/serialization/detail/*.hpp"
410)
411add_custom_target(serialization-detail SOURCES ${x})
412set_property(TARGET serialization-detail PROPERTY FOLDER "serialization")
413
414# for wserialization
415
416file(GLOB x
417 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
418 "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/*_w*.hpp"
419)
420add_custom_target(wserialization_headers SOURCES ${x})
421set_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
429add_executable( test_z ../test/test_z.cpp)
430target_link_libraries(test_z serialization wserialization ${Boost_LIBRARIES})
431
432# end test project
433#####################