boost_serialization 0.1.0

Boost C++ library boost_serialization packaged using Zanbil
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# CMake build control file for Serialization Library tests

cmake_minimum_required(VERSION 3.5)

if (POLICY CMP0054)
  cmake_policy (SET CMP0054 NEW)
endif (POLICY CMP0054)

if (POLICY CMP0063)
  cmake_policy (SET CMP0063 NEW)
endif (POLICY CMP0063)

project("serialization")

#
# Compiler settings
#

message(STATUS "C++ compiler is ${CMAKE_CXX_COMPILER_ID}" )
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
message(STATUS "C compiler is ${CMAKE_C_COMPILER_ID}" )

if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
  add_definitions( -ftemplate-depth=255 )
  # we use gcc to test for C++03 compatibility
  set(COMPILER_SUPPORTS_CXX11 FALSE)
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
  add_definitions( /wd4996 )
  set(COMPILER_SUPPORTS_CXX11 TRUE)
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=300")
  set(CMAKE_CXX_FLAGS_DEBUG "-g -O0" )
  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" )
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -dead_strip")
  set(COMPILER_SUPPORTS_CXX11 TRUE)
endif()

add_definitions( -std=c++11 )
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

#
# Locate Project Prerequisites 
#

# Boost

#
# Project settings
#
option(BUILD_SHARED_LIBS "Build Shared Libraries" true)

find_package(Boost 1.82 REQUIRED COMPONENTS system filesystem)

if(NOT Boost_FOUND)
  message("Boost NOT Found!")
else()
  message(STATUS "Boost Found!")
endif()
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(VISIBILITY_INLINES_HIDDEN YES)

# enable usage of CHECK_INCLUDE_FILE_CXX
include(CheckIncludeFileCXX)

# list of archive names for which tests should be generated
set(archive_list text_archive text_warchive binary_archive xml_archive xml_warchive)
# set(archive_list xml_warchive)

# list of tests generated by each function call
set(test_list)

###########################
# library builds

add_library(serialization
  ../src/archive_exception.cpp
  ../src/basic_archive.cpp
  ../src/basic_iarchive.cpp
  ../src/basic_iserializer.cpp
  ../src/basic_oarchive.cpp
  ../src/basic_oserializer.cpp
  ../src/basic_pointer_iserializer.cpp
  ../src/basic_pointer_oserializer.cpp
  ../src/basic_serializer_map.cpp
  ../src/basic_text_iprimitive.cpp
  ../src/basic_text_oprimitive.cpp
  ../src/basic_xml_archive.cpp
  ../src/binary_iarchive.cpp
  ../src/binary_oarchive.cpp
  ../src/extended_type_info.cpp
  ../src/extended_type_info_typeid.cpp
  ../src/extended_type_info_no_rtti.cpp
  ../src/stl_port.cpp
  ../src/text_iarchive.cpp
  ../src/text_oarchive.cpp
  ../src/polymorphic_iarchive.cpp
  ../src/polymorphic_oarchive.cpp
  ../src/polymorphic_text_iarchive.cpp
  ../src/polymorphic_text_oarchive.cpp
  ../src/polymorphic_binary_iarchive.cpp
  ../src/polymorphic_binary_oarchive.cpp
  ../src/polymorphic_xml_iarchive.cpp
  ../src/polymorphic_xml_oarchive.cpp
  ../src/void_cast.cpp
  ../src/xml_grammar.cpp
  ../src/xml_iarchive.cpp
  ../src/xml_oarchive.cpp
  ../src/xml_archive_exception.cpp
  ../src/codecvt_null.cpp
  ../src/utf8_codecvt_facet.cpp
  ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"'
)
target_include_directories(serialization PUBLIC ${Boost_INCLUDE_DIR})

add_library(wserialization
  ../src/basic_text_wiprimitive.cpp
  ../src/basic_text_woprimitive.cpp
  ../src/text_wiarchive.cpp
  ../src/text_woarchive.cpp
  ../src/polymorphic_text_wiarchive.cpp
  ../src/polymorphic_text_woarchive.cpp
  ../src/xml_wiarchive.cpp
  ../src/xml_woarchive.cpp
  ../src/polymorphic_xml_wiarchive.cpp
  ../src/polymorphic_xml_woarchive.cpp
  ../src/xml_wgrammar.cpp
  ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"'
)
target_include_directories(wserialization PUBLIC ${Boost_INCLUDE_DIR})
target_link_libraries(wserialization PUBLIC serialization)

# end library build
###########################

###########################
# test targets

function( serialization_test test_name)
  set(arglist)
  foreach(a IN ITEMS ${ARGN} )
    set(arglist ${arglist} ../test/${a}.cpp)
  endforeach()
  message(STATUS ${test_name})
  add_executable( ${test_name} ../test/${test_name}.cpp ${arglist} )
  target_include_directories(${test_name} PUBLIC ${Boost_INCLUDE_DIR})
  target_link_libraries(${test_name} serialization wserialization Boost::filesystem)
  add_test( ${test_name} ${test_name} )
endfunction(serialization_test)

function(archive_test test_name)
  set(test_listx)
  set(arglist)
  foreach(a IN ITEMS ${ARGN} )
    set(arglist ${arglist} ../test/${a}.cpp)
  endforeach()
  foreach(
    archive-name
    IN ITEMS ${archive_list}
  )
    set(amended_test_name ${test_name}_${archive-name})
    add_executable(${amended_test_name} ../test/${test_name}.cpp ${arglist})
    set_property(
      TARGET ${amended_test_name}
      PROPERTY COMPILE_DEFINITIONS BOOST_ARCHIVE_TEST=${archive-name}.hpp
    )
    target_include_directories(${amended_test_name} PUBLIC ${Boost_INCLUDE_DIR})
    target_link_libraries(${amended_test_name} serialization wserialization Boost::filesystem)
    add_test(${amended_test_name} ${amended_test_name})
    set(test_listx ${test_listx} ${amended_test_name})
  endforeach()
  set(test_list ${test_listx} PARENT_SCOPE)
endfunction(archive_test)

function(polymorphic_archive_test test_name)
  set(test_listx)
  set(arglist)
  foreach(a IN ITEMS ${ARGN} )
    set(arglist ${arglist} ../test/${a}.cpp)
  endforeach()
  foreach(
    archive-name
    IN ITEMS ${archive_list}
  )
    set(amended_archive_name polymorphic_${archive-name})
    set(amended_test_name ${test_name}_${amended_archive_name})
    add_executable(${amended_test_name} ../test/${test_name}.cpp ${arglist})
    set_property(
      TARGET ${amended_test_name}
      PROPERTY COMPILE_DEFINITIONS BOOST_ARCHIVE_TEST=${amended_archive_name}.hpp
    )
    message(STATUS ${amended_test_name} " " ${arglist} " " ${amended_archive_name})
    target_include_directories(${amended_test_name} PUBLIC ${Boost_INCLUDE_DIR})
    target_link_libraries(${amended_test_name} serialization wserialization Boost::filesystem)
    add_test(${amended_test_name} ${amended_test_name})
    set(test_listx ${test_listx} ${amended_test_name})
endforeach()
set(test_list ${test_listx} PARENT_SCOPE)
endfunction(polymorphic_archive_test)

enable_testing()

message(STATUS dll_a)
add_library(dll_a SHARED ../test/dll_a.cpp)
target_link_libraries(dll_a serialization)

message(STATUS dll_polymorphic_base)
add_library(dll_polymorphic_base SHARED ../test/dll_polymorphic_base.cpp)
target_link_libraries(dll_polymorphic_base serialization)

message(STATUS dll_polymorphic_derived2)
add_library(dll_polymorphic_derived2 SHARED ../test/dll_polymorphic_derived2.cpp)
target_link_libraries(dll_polymorphic_derived2 dll_polymorphic_base serialization)

# compile test_dll_plugin.cpp
# Running the following test requires that the test know the directory 
# in which the dll is stored. I don't know how to extract this from bjam
# serialization(test_dll_plugin : : dll_polymorphic_derived2_lib)

if(BUILD_SHARED_LIBS)
  # this test can only be made to work if we're linking with shared
  # libraries. Basically the build systems like to have all shared
  # or all static so if we're building with static C++ libraries
  # then linking with a shared one - we need multiple C++ libraries
  # and things get complex.  So just run this test when we're
  # building with shared libraries (dll in windows speak)
  serialization_test(test_dll_simple)
  target_link_libraries(test_dll_simple dll_a serialization)
endif()

serialization_test(test_private_ctor)
serialization_test(test_reset_object_address A)
serialization_test(test_void_cast)
serialization_test(test_mult_archive_types)
serialization_test(test_iterators)
serialization_test(test_iterators_base64)
serialization_test(test_inclusion)
serialization_test(test_inclusion2)
serialization_test(test_smart_cast)
serialization_test(test_codecvt_null)
serialization_test(test_strong_typedef)
serialization_test(test_singleton)
serialization_test(test_singleton_inherited)
serialization_test(test_singleton_plain)

archive_test(test_native_array A)
archive_test(test_boost_array A)
if(COMPILER_SUPPORTS_CXX11)
  archive_test(test_array A)
endif()

archive_test(test_binary)
archive_test(test_bitset)
archive_test(test_class_info_save)
archive_test(test_class_info_load)
archive_test(test_complex)
archive_test(test_contained_class A)
archive_test(test_cyclic_ptrs A)
archive_test(test_delete_pointer)
archive_test(test_deque A)
archive_test(test_derived)
archive_test(test_derived_class A)
archive_test(test_diamond)
archive_test(test_diamond_complex)
CHECK_INCLUDE_FILE_CXX(forward_list FORWARD_LIST_FOUND)
if(FORWARD_LIST_FOUND)
  message(STATUS "forward_list header found")
  archive_test(test_forward_list A)
  archive_test(test_forward_list_ptrs A)
else()
  message(STATUS "forward_list header NOT found")
endif()

archive_test(test_helper_support)
archive_test(test_interrupts)
archive_test(test_list A)
archive_test(test_list_ptrs A)

archive_test(test_map A)
CHECK_INCLUDE_FILE_CXX(hash_map HASH_MAP_FOUND)
if(HASH_MAP_FOUND)
  archive_test(test_map_hashed A)
endif()
archive_test(test_mi)
archive_test(test_multiple_ptrs A)
archive_test(test_multiple_inheritance)
archive_test(test_new_operator A)
archive_test(test_non_intrusive)
archive_test(test_non_default_ctor)
archive_test(test_non_default_ctor2)
archive_test(test_null_ptr)
archive_test(test_nvp A)
archive_test(test_object)
archive_test(test_optional)
archive_test(test_primitive)
archive_test(test_priority_queue A)
archive_test(test_private_base)
archive_test(test_private_base2)
archive_test(test_queue A)
archive_test(test_recursion A)
archive_test(test_registered)

archive_test(test_set A)
CHECK_INCLUDE_FILE_CXX(hash_set HASH_SET_FOUND)
if(HASH_SET_FOUND)
  archive_test(test_set_hashed A)
endif()

archive_test(test_shared_ptr)
archive_test(test_shared_ptr_multi_base)
archive_test(test_shared_ptr_132)
archive_test(test_simple_class A)
archive_test(test_simple_class_ptr A)
CHECK_INCLUDE_FILE_CXX(slist SLIST_FOUND)
if(SLIST_FOUND)
  message(STATUS "slist header found")
  archive_test(test_slist A)
  archive_test(test_slist_ptr A)
endif()
archive_test(test_stack A)
archive_test(test_split)
archive_test(test_tracking)
archive_test(test_unregistered)
archive_test(test_unique_ptr)
archive_test(test_valarray)
archive_test(test_variant A)
archive_test(test_vector A)

if(BUILD_SHARED_LIBS)
  polymorphic_archive_test(test_dll_exported polymorphic_derived1)
  foreach(test_name IN ITEMS ${test_list} )
    target_link_libraries(${test_name} dll_polymorphic_derived2 dll_polymorphic_base serialization wserialization)
  endforeach()
endif()

polymorphic_archive_test(test_no_rtti polymorphic_base polymorphic_derived1 polymorphic_derived2)
polymorphic_archive_test(test_exported polymorphic_base polymorphic_derived1 polymorphic_derived2)
polymorphic_archive_test(test_polymorphic test_polymorphic_A A)
polymorphic_archive_test(test_polymorphic2 test_polymorphic2imp)
polymorphic_archive_test(test_p_helper)

# end test targets
####################

####################
# add headers in IDE

# for serialization

file(GLOB x 
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 
  "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/*.hpp"
)
add_custom_target(archive SOURCES ${x})
set_property(TARGET archive PROPERTY FOLDER "serialization")

file(GLOB x 
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 
  "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/detail/*.hpp"
)
add_custom_target(archive-detail SOURCES ${x})
set_property(TARGET archive-detail PROPERTY FOLDER "serialization")

file(GLOB x 
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 
  "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/impl/*.ipp"
)
add_custom_target(archive-impl SOURCES ${x})
set_property(TARGET archive-impl PROPERTY FOLDER "serialization")

file(GLOB x
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 
  "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/iterators/*.hpp"
)
add_custom_target(archive-iterators SOURCES ${x})
set_property(TARGET archive-iterators PROPERTY FOLDER "serialization")

file(GLOB x 
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 
  "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/serialization/*.hpp"
)
add_custom_target(serialization-headers SOURCES ${x})
set_property(TARGET serialization-headers PROPERTY FOLDER "serialization")

file(GLOB x 
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 
  "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/serialization/detail/*.hpp"
)
add_custom_target(serialization-detail SOURCES ${x})
set_property(TARGET serialization-detail PROPERTY FOLDER "serialization")

# for wserialization

file(GLOB x 
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 
  "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/*_w*.hpp"
)
add_custom_target(wserialization_headers SOURCES ${x})
set_property(TARGET wserialization_headers PROPERTY FOLDER "wserialization")

# end headers in IDE
####################

#####################
# add test project to run misc tests

add_executable( test_z ../test/test_z.cpp)
target_link_libraries(test_z serialization wserialization ${Boost_LIBRARIES})

# end test project
#####################