Skip to content

Commit

Permalink
Merge branch 'tusharpm-develop' into develop
Browse files Browse the repository at this point in the history
see USCiLab#373

Still need to address why windows needed a modifcation to polymorphic test to compile
  • Loading branch information
AzothAmmo committed Jan 27, 2017
2 parents 4a92e29 + e4d543d commit a2d5a15
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 19 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
35 changes: 35 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# can use variables like {build} and {branch}
version: 1.2.{build}
pull_requests:
do_not_increment_build_number: true

branches:
only:
- develop

configuration:
- Debug
- Release

environment:
matrix:
- VS_VERSION_MAJOR: 12
- VS_VERSION_MAJOR: 14
BOOST_ROOT: C:\Libraries\boost_1_59_0

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
3 changes: 3 additions & 0 deletions sandbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
75 changes: 75 additions & 0 deletions scripts/appveyor.bat
Original file line number Diff line number Diff line change
@@ -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%
30 changes: 22 additions & 8 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=$<TARGET_FILE_DIR:portability_test64>
-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
Expand All @@ -31,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")
Expand Down
3 changes: 3 additions & 0 deletions unittests/polymorphic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ struct PolyDerivedD : PolyBaseB, PolyBaseC
};

CEREAL_REGISTER_TYPE(PolyDerivedD)
#ifdef _MSC_VER
CEREAL_REGISTER_POLYMORPHIC_RELATION(PolyBaseA, PolyDerivedD)
#endif

struct PolyBase
{
Expand Down
16 changes: 16 additions & 0 deletions unittests/run_portability_test.cmake
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 0 additions & 9 deletions unittests/run_portability_test.sh

This file was deleted.

0 comments on commit a2d5a15

Please sign in to comment.