diff --git a/CMakeLists.txt b/CMakeLists.txt index c2c269b56..b77a3f82e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.6.2) project (cereal) -option(SKIP_PORTABILITY_TEST "Skip portability tests" OFF) +option(SKIP_PORTABILITY_TEST "Skip portability (32 bit) tests" OFF) if(NOT CMAKE_VERSION VERSION_LESS 3.0) # installing cereal requires INTERFACE lib option(JUST_INSTALL_CEREAL "Don't do anything besides installing the library" OFF) endif() @@ -49,13 +49,15 @@ endif() include_directories(./include) -find_package(Boost COMPONENTS serialization unit_test_framework) +# Boost serialization for performance sandbox +find_package(Boost COMPONENTS serialization) if(Boost_FOUND) include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) - enable_testing() - add_subdirectory(unittests) endif(Boost_FOUND) + +enable_testing() +add_subdirectory(unittests) add_subdirectory(sandbox) diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index ae221d038..a5a91ae30 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -1,6 +1,6 @@ file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) -# A semi-colon separated list of test sources that should not be automatically built with boost unit test +# A semi-colon separated list of test sources that should not be automatically built with doctest set(SPECIAL_TESTS "portability_test.cpp") # Build the portability test only if we are on a 64-bit machine (void* is 8 bytes) @@ -15,7 +15,7 @@ if((${CMAKE_SIZEOF_VOID_P} EQUAL 8) AND (NOT SKIP_PORTABILITY_TEST)) endif() -# Build all of the non-special tests and link against the boost unit test framework +# Build all of the non-special tests foreach(TEST_SOURCE ${TESTS}) string(REPLACE ".cpp" "" TEST_TARGET "${TEST_SOURCE}") @@ -27,21 +27,16 @@ foreach(TEST_SOURCE ${TESTS}) if(IS_SPECIAL_TEST EQUAL -1) add_executable(${TEST_TARGET} ${TEST_SOURCE}) - set_target_properties(${TEST_TARGET} PROPERTIES COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK;BOOST_TEST_MODULE=${TEST_TARGET}") - target_link_libraries(${TEST_TARGET} ${Boost_LIBRARIES}) target_link_libraries(${TEST_TARGET} ${CEREAL_THREAD_LIBS}) add_test("${TEST_TARGET}" "${TEST_TARGET}") - # TODO: This won't work right now, because we would need a 32-bit boost - ## If we are on a 64-bit machine, create an extra 32-bit version of the test - #if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - # add_executable(${TEST_TARGET}_32 ${TEST_SOURCE}) - # set_target_properties(${TEST_TARGET}_32 PROPERTIES - # COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK;BOOST_TEST_MODULE=${TEST_TARGET}" - # COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") - # target_link_libraries(${TEST_TARGET}_32 ${Boost_LIBRARIES}) - # add_test("${TEST_TARGET}_32" "${TEST_TARGET}_32") - #endif() + # If we are on a 64-bit machine, create an extra 32-bit version of the test if portability testing is enabled + if((${CMAKE_SIZEOF_VOID_P} EQUAL 8) AND (NOT SKIP_PORTABILITY_TEST)) + add_executable(${TEST_TARGET}_32 ${TEST_SOURCE}) + set_target_properties(${TEST_TARGET}_32 PROPERTIES + COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") + add_test("${TEST_TARGET}_32" "${TEST_TARGET}_32") + endif() endif() @@ -69,11 +64,9 @@ foreach(TEST_SOURCE ${TESTS}) add_dependencies(coverage ${COVERAGE_TARGET}) add_executable(${COVERAGE_TARGET} EXCLUDE_FROM_ALL ${TEST_SOURCE}) - set_target_properties(${COVERAGE_TARGET} PROPERTIES COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK;BOOST_TEST_MODULE=${COVERAGE_TARGET}") set_target_properties(${COVERAGE_TARGET} PROPERTIES COMPILE_FLAGS "-coverage") set_target_properties(${COVERAGE_TARGET} PROPERTIES LINK_FLAGS "-coverage") set_target_properties(${COVERAGE_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/coverage") - target_link_libraries(${COVERAGE_TARGET} ${Boost_LIBRARIES}) target_link_libraries(${COVERAGE_TARGET} ${CEREAL_THREAD_LIBS}) endif() endforeach() diff --git a/unittests/complex.cpp b/unittests/complex.cpp index e7b9ff714..168d1038c 100644 --- a/unittests/complex.cpp +++ b/unittests/complex.cpp @@ -27,7 +27,7 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "complex.hpp" -TEST_SUITE("complex") +TEST_SUITE("complex"); TEST_CASE("binary_complex") {