From d16feb9de8ecd18caad75b0bee410e994a174265 Mon Sep 17 00:00:00 2001 From: Shane Grant Date: Tue, 7 May 2019 22:27:17 -0700 Subject: [PATCH] Appveyor updates + boost testing fixes -Fixes appveyor CI and adds additional MSVC versions -Puts boost variant test building behind boost requirement --- CMakeLists.txt | 4 +++ appveyor.yml | 15 ++++++++-- scripts/appveyor.bat | 5 ++++ unittests/CMakeLists.txt | 4 +++ unittests/boost/CMakeLists.txt | 38 +++++++++++++++++++++++++ unittests/{ => boost}/boost_variant.cpp | 0 unittests/{ => boost}/boost_variant.hpp | 2 +- 7 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 unittests/boost/CMakeLists.txt rename unittests/{ => boost}/boost_variant.cpp (100%) rename unittests/{ => boost}/boost_variant.hpp (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d51741af..3425df08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,10 @@ endif() include_directories(./include) +if(NOT CMAKE_VERSION VERSION_LESS 3.12) + cmake_policy(VERSION 3.12) +endif() + # Boost serialization for performance sandbox find_package(Boost COMPONENTS serialization) diff --git a/appveyor.yml b/appveyor.yml index 121eba15..64befabd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,9 +13,18 @@ configuration: environment: matrix: - - VS_VERSION_MAJOR: 12 - - VS_VERSION_MAJOR: 14 - BOOST_ROOT: C:\Libraries\boost_1_59_0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + VS_VERSION_MAJOR: 12 + BOOST_ROOT: C:\Libraries\boost_1_58_0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + VS_VERSION_MAJOR: 14 + BOOST_ROOT: C:\Libraries\boost_1_60_0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + VS_VERSION_MAJOR: 15 + BOOST_ROOT: C:\Libraries\boost_1_66_0 + # - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 Preview + # VS_VERSION_MAJOR: 16 + # BOOST_ROOT: C:\Libraries\boost_1_66_0 platform: - Win32 diff --git a/scripts/appveyor.bat b/scripts/appveyor.bat index 5e478dec..7cc77c8b 100644 --- a/scripts/appveyor.bat +++ b/scripts/appveyor.bat @@ -10,6 +10,7 @@ if not defined APPVEYOR ( if not defined BOOST_ROOT ( set BOOST_ROOT=C:\Libraries\boost ) + if not defined VS_VERSION_MAJOR ( set VS_VERSION_MAJOR=14 ) @@ -18,6 +19,10 @@ if not defined VS_VERSION_YEAR ( set VS_VERSION_YEAR=2013 ) else if "%VS_VERSION_MAJOR%" == "14" ( set VS_VERSION_YEAR=2015 + ) else if "%VS_VERSION_MAJOR%" == "15" ( + set VS_VERSION_YEAR=2017 + ) else if "%VS_VERSION_MAJOR%" == "16" ( + set VS_VERSION_YEAR=2019 ) else ( @echo Cannot use Visual Studio version %VS_VERSION_MAJOR% exit /b 1 diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 83f1cb18..3c948cc4 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -91,6 +91,10 @@ if(CMAKE_CXX_STANDARD GREATER 14) add_subdirectory(cpp17) endif() +if(Boost_FOUND) + add_subdirectory(boost) +endif() + if(NOT CMAKE_VERSION VERSION_LESS 3.0) add_test(test_cmake_config_module ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake-config-module.cmake) endif() diff --git a/unittests/boost/CMakeLists.txt b/unittests/boost/CMakeLists.txt new file mode 100644 index 00000000..3c9b110e --- /dev/null +++ b/unittests/boost/CMakeLists.txt @@ -0,0 +1,38 @@ +file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) + +# Build all of the non-special tests +foreach(TEST_SOURCE ${TESTS}) + message(STATUS ${TEST_SOURCE}) + + string(REPLACE ".cpp" "" TEST_TARGET "${TEST_SOURCE}") + set(TEST_TARGET "test_${TEST_TARGET}") + + add_executable(${TEST_TARGET} ${TEST_SOURCE}) + target_link_libraries(${TEST_TARGET} ${CEREAL_THREAD_LIBS}) + add_test("${TEST_TARGET}" "${TEST_TARGET}") + + # If we are on a 64-bit machine, create an extra 32-bit version of the test if portability testing is enabled + if((NOT MSVC) AND (${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() + +endforeach() + +if(NOT MSVC) + # add tests to coverage + foreach(TEST_SOURCE ${TESTS}) + string(REPLACE ".cpp" "" COVERAGE_TARGET "${TEST_SOURCE}") + set(COVERAGE_TARGET "coverage_${COVERAGE_TARGET}") + + add_dependencies(coverage ${COVERAGE_TARGET}) + + add_executable(${COVERAGE_TARGET} EXCLUDE_FROM_ALL ${TEST_SOURCE}) + 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} ${CEREAL_THREAD_LIBS}) + endforeach() +endif(NOT MSVC) diff --git a/unittests/boost_variant.cpp b/unittests/boost/boost_variant.cpp similarity index 100% rename from unittests/boost_variant.cpp rename to unittests/boost/boost_variant.cpp diff --git a/unittests/boost_variant.hpp b/unittests/boost/boost_variant.hpp similarity index 99% rename from unittests/boost_variant.hpp rename to unittests/boost/boost_variant.hpp index bedb6a89..d189685d 100644 --- a/unittests/boost_variant.hpp +++ b/unittests/boost/boost_variant.hpp @@ -27,7 +27,7 @@ #ifndef CEREAL_TEST_BOOST_VARIANT_H_ #define CEREAL_TEST_BOOST_VARIANT_H_ -#include "common.hpp" +#include "../common.hpp" #include template inline