]> git.proxmox.com Git - ceph.git/blob - ceph/src/rapidjson/test/unittest/CMakeLists.txt
update sources to v12.1.0
[ceph.git] / ceph / src / rapidjson / test / unittest / CMakeLists.txt
1 include(CheckCXXCompilerFlag)
2
3 set(UNITTEST_SOURCES
4 allocatorstest.cpp
5 bigintegertest.cpp
6 documenttest.cpp
7 dtoatest.cpp
8 encodedstreamtest.cpp
9 encodingstest.cpp
10 fwdtest.cpp
11 filestreamtest.cpp
12 itoatest.cpp
13 istreamwrappertest.cpp
14 jsoncheckertest.cpp
15 namespacetest.cpp
16 pointertest.cpp
17 prettywritertest.cpp
18 ostreamwrappertest.cpp
19 readertest.cpp
20 regextest.cpp
21 schematest.cpp
22 simdtest.cpp
23 strfunctest.cpp
24 stringbuffertest.cpp
25 strtodtest.cpp
26 unittest.cpp
27 valuetest.cpp
28 writertest.cpp)
29
30 find_program(CCACHE_FOUND ccache)
31 if(CCACHE_FOUND)
32 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
33 set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
34 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
35 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
36 endif()
37 endif(CCACHE_FOUND)
38
39 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
40 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal")
41 elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
42 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything")
43 # If the user is running a newer version of Clang that includes the
44 # -Wdouble-promotion, we will ignore that warning.
45 if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.7)
46 CHECK_CXX_COMPILER_FLAG("-Wno-double-promotion" HAS_NO_DOUBLE_PROMOTION)
47 if (HAS_NO_DOUBLE_PROMOTION)
48 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-double-promotion")
49 endif()
50 endif()
51 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
52 # Force to always compile with /W4
53 if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
54 string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
55 else()
56 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
57 endif()
58
59 # Force to always compile with /WX
60 if(CMAKE_CXX_FLAGS MATCHES "/WX-")
61 string(REGEX REPLACE "/WX-" "/WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
62 else()
63 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
64 endif()
65 endif()
66
67 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRAPIDJSON_HAS_STDSTRING=1")
68
69 add_library(namespacetest STATIC namespacetest.cpp)
70
71 add_executable(unittest ${UNITTEST_SOURCES})
72 target_link_libraries(unittest ${TEST_LIBRARIES} namespacetest)
73
74 add_dependencies(tests unittest)
75
76 add_test(NAME unittest
77 COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest
78 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
79
80 if(NOT MSVC)
81 # Not running SIMD.* unit test cases for Valgrind
82 add_test(NAME valgrind_unittest
83 COMMAND valgrind --leak-check=full --error-exitcode=1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest --gtest_filter=-SIMD.*
84 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
85
86 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
87 add_test(NAME symbol_check
88 COMMAND sh -c "objdump -t -C libnamespacetest.a | grep rapidjson ; test $? -ne 0"
89 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
90 endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
91
92 endif(NOT MSVC)