CMakeLists.txt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. set(UNITTEST_SOURCES
  2. allocatorstest.cpp
  3. bigintegertest.cpp
  4. documenttest.cpp
  5. encodedstreamtest.cpp
  6. encodingstest.cpp
  7. fwdtest.cpp
  8. filestreamtest.cpp
  9. itoatest.cpp
  10. istreamwrappertest.cpp
  11. jsoncheckertest.cpp
  12. namespacetest.cpp
  13. pointertest.cpp
  14. prettywritertest.cpp
  15. ostreamwrappertest.cpp
  16. readertest.cpp
  17. regextest.cpp
  18. schematest.cpp
  19. simdtest.cpp
  20. strfunctest.cpp
  21. stringbuffertest.cpp
  22. strtodtest.cpp
  23. unittest.cpp
  24. valuetest.cpp
  25. writertest.cpp)
  26. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  27. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal")
  28. elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  29. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything")
  30. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  31. add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
  32. endif()
  33. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRAPIDJSON_HAS_STDSTRING=1")
  34. add_library(namespacetest STATIC namespacetest.cpp)
  35. add_executable(unittest ${UNITTEST_SOURCES})
  36. target_link_libraries(unittest ${TEST_LIBRARIES} namespacetest)
  37. add_dependencies(tests unittest)
  38. add_test(NAME unittest
  39. COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest
  40. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
  41. if(NOT MSVC)
  42. # Not running SIMD.* unit test cases for Valgrind
  43. add_test(NAME valgrind_unittest
  44. COMMAND valgrind --leak-check=full --error-exitcode=1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest --gtest_filter=-SIMD.*
  45. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
  46. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  47. add_test(NAME symbol_check
  48. COMMAND sh -c "objdump -t -C libnamespacetest.a | grep rapidjson ; test $? -ne 0"
  49. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
  50. endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
  51. endif(NOT MSVC)