From 0a908bc8c857ed51f5886066efd459884ff63544 Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Sat, 10 Dec 2016 17:27:28 +0530 Subject: [PATCH 1/6] Make tests pass with Windows --- CMakeLists.txt | 6 ++++-- sandbox/CMakeLists.txt | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0d53dbd2..ad4b7e902 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,10 @@ else() set(CEREAL_THREAD_LIBS "") endif() -if(NOT MSVC) - set(CMAKE_CXX_FLAGS "-Wall -g -Wextra -Wshadow -pedantic -Wold-style-cast ${CMAKE_CXX_FLAGS}") +if(MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") +else() + set(CMAKE_CXX_FLAGS "-Wall -g -Wextra -Wshadow -pedantic -Wold-style-cast ${CMAKE_CXX_FLAGS}") option(WITH_WERROR "Compile with '-Werror' C++ compiler flag" ON) if(WITH_WERROR) set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}") diff --git a/sandbox/CMakeLists.txt b/sandbox/CMakeLists.txt index 5008e420f..52c8df890 100644 --- a/sandbox/CMakeLists.txt +++ b/sandbox/CMakeLists.txt @@ -10,5 +10,8 @@ include_directories(sandbox_shared_lib) if(Boost_FOUND) add_executable(performance performance.cpp) + if(MSVC) + set_target_properties(performance PROPERTIES COMPILE_DEFINITIONS "BOOST_SERIALIZATION_DYN_LINK") + endif() target_link_libraries(performance ${Boost_LIBRARIES}) endif(Boost_FOUND) From df44243badd997642693c98541a408459009fe64 Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Sun, 11 Dec 2016 01:01:10 +0530 Subject: [PATCH 2/6] Enable cross-platform portability test CMake fix 32-bit executable with generator Win64 --- unittests/CMakeLists.txt | 28 +++++++++++++++++++++------- unittests/run_portability_test.cmake | 16 ++++++++++++++++ unittests/run_portability_test.sh | 9 --------- 3 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 unittests/run_portability_test.cmake delete mode 100755 unittests/run_portability_test.sh diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index a5a91ae30..3212fb488 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -3,16 +3,30 @@ file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) # 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) -if((${CMAKE_SIZEOF_VOID_P} EQUAL 8) AND (NOT SKIP_PORTABILITY_TEST)) - add_executable(portability_test32 portability_test.cpp) - set_target_properties(portability_test32 PROPERTIES COMPILE_FLAGS "-m32") - set_target_properties(portability_test32 PROPERTIES LINK_FLAGS "-m32") +if(CMAKE_VERSION VERSION_LESS 2.8) + # Portability test uses the `TARGET_FILE_DIR` generator expression which is available from CMake 2.8. + set(SKIP_PORTABILITY_TEST ON) +endif() + +if(NOT SKIP_PORTABILITY_TEST) + # Build the portability test only if we are on a 64-bit machine (void* is 8 bytes) + if((${CMAKE_SIZEOF_VOID_P} EQUAL 8)) + if(NOT MSVC) + add_executable(portability_test32 portability_test.cpp) + set_target_properties(portability_test32 PROPERTIES COMPILE_FLAGS "-m32") + set_target_properties(portability_test32 PROPERTIES LINK_FLAGS "-m32") + endif() - add_executable(portability_test64 portability_test.cpp) + add_executable(portability_test64 portability_test.cpp) - add_test(NAME portability_test COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/run_portability_test.sh") + add_test(NAME portability_test + COMMAND ${CMAKE_COMMAND} + -DPORTABILITY_TEST_DIR=$ + -P "${CMAKE_CURRENT_SOURCE_DIR}/run_portability_test.cmake") + elseif(MSVC) + add_executable(portability_test32 portability_test.cpp) + endif() endif() # Build all of the non-special tests diff --git a/unittests/run_portability_test.cmake b/unittests/run_portability_test.cmake new file mode 100644 index 000000000..2841e6c35 --- /dev/null +++ b/unittests/run_portability_test.cmake @@ -0,0 +1,16 @@ +macro(EXEC_CMD_CHECK) + message("running ${ARGN}") + execute_process(COMMAND ${ARGN} RESULT_VARIABLE CMD_RESULT) + if(CMD_RESULT) + message(FATAL_ERROR "Error running ${ARGN}") + endif() +endmacro() + +set(PORTABILITY_TEST_32 "${PORTABILITY_TEST_DIR}/portability_test32") +set(PORTABILITY_TEST_64 "${PORTABILITY_TEST_DIR}/portability_test64") + +exec_cmd_check(${PORTABILITY_TEST_64} save 64) +exec_cmd_check(${PORTABILITY_TEST_32} load 32) +exec_cmd_check(${PORTABILITY_TEST_32} save 32) +exec_cmd_check(${PORTABILITY_TEST_64} load 64) +exec_cmd_check(${PORTABILITY_TEST_64} remove 64) diff --git a/unittests/run_portability_test.sh b/unittests/run_portability_test.sh deleted file mode 100755 index 718440284..000000000 --- a/unittests/run_portability_test.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -e - -./portability_test64 save 64 -./portability_test32 load 32 -./portability_test32 save 32 -./portability_test64 load 64 -./portability_test64 remove 64 From 655696ad8119b2dad041d5d1fa955ed9a67a2a7c Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Sun, 11 Dec 2016 15:42:00 +0530 Subject: [PATCH 3/6] AppVeyor integration --- appveyor.yml | 32 +++++++++++++++++++ scripts/appveyor.bat | 75 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 appveyor.yml create mode 100644 scripts/appveyor.bat diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..c45695d83 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,32 @@ +# can use variables like {build} and {branch} +version: 1.2.{build} + +branches: + only: + - develop + +configuration: + - Debug + - Release + +environment: + matrix: + - VS_VERSION_MAJOR: 12 + - VS_VERSION_MAJOR: 14 + +platform: + - Win32 + - x64 + +before_build: "scripts\\appveyor.bat" + +build: + parallel: true + project: build/cereal.sln + verbosity: minimal + +test_script: "scripts\\appveyor.bat test" + +artifacts: + - path: build\Testing + - path: out diff --git a/scripts/appveyor.bat b/scripts/appveyor.bat new file mode 100644 index 000000000..5e478dece --- /dev/null +++ b/scripts/appveyor.bat @@ -0,0 +1,75 @@ +@echo off +setlocal enabledelayedexpansion + +if not defined APPVEYOR ( + @echo This script is meant to be used with AppVeyor CI. This can be used as reference. + @echo I sincerely recommend not using it for building/testing cereal locally. + exit /b 0 +) + +if not defined BOOST_ROOT ( + set BOOST_ROOT=C:\Libraries\boost +) +if not defined VS_VERSION_MAJOR ( + set VS_VERSION_MAJOR=14 +) +if not defined VS_VERSION_YEAR ( + if "%VS_VERSION_MAJOR%" == "12" ( + set VS_VERSION_YEAR=2013 + ) else if "%VS_VERSION_MAJOR%" == "14" ( + set VS_VERSION_YEAR=2015 + ) else ( + @echo Cannot use Visual Studio version %VS_VERSION_MAJOR% + exit /b 1 + ) +) +if not defined CMAKE_GENERATOR_PREFIX ( + set CMAKE_GENERATOR_PREFIX=Visual Studio %VS_VERSION_MAJOR% %VS_VERSION_YEAR% +) + +@rem CONFIGURATION is (one of the entries) defined in appveyor.yml +if not defined CONFIGURATION ( + set CONFIGURATION=Release +) +@rem PLATFORM is (one of the entries) defined in appveyor.yml +if "%PLATFORM%"=="x64" ( + set BIT_COUNT=64 + set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_PREFIX% Win64 +) else ( + set BIT_COUNT=32 + set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_PREFIX% +) + +set BOOST_LIBRARYDIR=%BOOST_ROOT%\lib%BIT_COUNT%-msvc-%VS_VERSION_MAJOR%.0 + +set START_DIR=%CD% + +if not exist build\NUL mkdir build +cd build + +if "%~1" == "test" ( + @rem overloading the batch script; Run tests if the first argument is `test` (without quotes). + @rem Cereal uses Boost Unit test framework. Rather than modifying the code to load boost test + @rem dll from its location OR copying the boost dlls to the directory of every test being run, + @rem we use another option Windows leaves us - modify the PATH. + for %%i in (ctest.exe) do set CTEST_EXE=%%~$PATH:i + PATH %BOOST_LIBRARYDIR% + "!CTEST_EXE!" -C %CONFIGURATION% + if %errorlevel% neq 0 exit /b %errorlevel% + goto done +) + +if "%PLATFORM%" == "x64" ( + @rem please excuse the hack - CMake is unable to produce multiarch MSVC projects + cmake -G "%CMAKE_GENERATOR_PREFIX%" -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% .. + cmake --build . --config %CONFIGURATION% --target portability_test32 + del CMakeCache.txt + rmdir /s /q CMakeFiles +) + +cmake -G "%CMAKE_GENERATOR_NAME%" -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% .. +@rem left the actual build for later - AppVeyor enables parallel jobs in a much cleaner way than msbuild + +:done +@REM go back home +cd %START_DIR% From 4ff4db8532a41b2cedca069d64c3ef970961c6d3 Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Sun, 11 Dec 2016 20:03:02 +0530 Subject: [PATCH 4/6] boost new version --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index c45695d83..6540590c1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,6 +13,7 @@ environment: matrix: - VS_VERSION_MAJOR: 12 - VS_VERSION_MAJOR: 14 + BOOST_ROOT: C:\Libraries\boost_1_59_0 platform: - Win32 From 2261feea2f307e3a0102223faff43a6710c93967 Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Sun, 18 Dec 2016 17:32:04 +0530 Subject: [PATCH 5/6] Pull requests to not increment build numbers --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 6540590c1..121eba152 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,7 @@ # can use variables like {build} and {branch} version: 1.2.{build} +pull_requests: + do_not_increment_build_number: true branches: only: From e4d543d0b4fbda2d4235defe79fca1944ac9c7c0 Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Thu, 26 Jan 2017 16:53:47 +0530 Subject: [PATCH 6/6] Fix merge issues --- unittests/CMakeLists.txt | 2 +- unittests/polymorphic.hpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 3212fb488..4ce2cb62d 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -45,7 +45,7 @@ foreach(TEST_SOURCE ${TESTS}) 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((${CMAKE_SIZEOF_VOID_P} EQUAL 8) AND (NOT SKIP_PORTABILITY_TEST)) + 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") diff --git a/unittests/polymorphic.hpp b/unittests/polymorphic.hpp index d882cc0af..52c6ae279 100644 --- a/unittests/polymorphic.hpp +++ b/unittests/polymorphic.hpp @@ -131,6 +131,9 @@ struct PolyDerivedD : PolyBaseB, PolyBaseC }; CEREAL_REGISTER_TYPE(PolyDerivedD) +#ifdef _MSC_VER +CEREAL_REGISTER_POLYMORPHIC_RELATION(PolyBaseA, PolyDerivedD) +#endif struct PolyBase {