Skip to content

Commit

Permalink
Removed boost_test as a requirement
Browse files Browse the repository at this point in the history
-Now build 32 bit unit tests if portability testing is enabled
-No more boost+clang issues over std::string abi
see USCiLab#139, USCiLab#123
  • Loading branch information
AzothAmmo committed Nov 4, 2016
1 parent 66528b6 commit 1d67d44
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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)

Expand Down
25 changes: 9 additions & 16 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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}")
Expand All @@ -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()

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion unittests/complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "complex.hpp"

TEST_SUITE("complex")
TEST_SUITE("complex");

TEST_CASE("binary_complex")
{
Expand Down

0 comments on commit 1d67d44

Please sign in to comment.