Skip to content

Commit

Permalink
Fix running tests on Windows when built as Release target
Browse files Browse the repository at this point in the history
* tests/CMakeLists.txt: Fix running tests on Windows when engine is
built with optimizations enabled (Release build target). GTest was
throwing SEH exception code 0xc0000005 errors due to a mismatch in
the library type used -- debug VS release libraries. Unit tests
now will use the appropriate library target type when the engine
is switched between configuration types (Debug && Release).
  This fix has only been tested with the ActionTest executable so
far.

* third-party/README.md: Update GTest documentation notes for Windows
to include build info for how I built the GTest libraries for Release
builds. See https://sourceforge.net/projects/nomlib/files/ for latest
built libraries.
  • Loading branch information
i8degrees committed Mar 15, 2015
1 parent b6b83ca commit c7fdf2f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
28 changes: 11 additions & 17 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@
# NOTE: You may need to issue a 'make rebuild_cache' after changing test
# fixture names, in order to get 'make test' to recognize the modified test
# code.
#
# NOTE: To display a unit test's full debugging output (NOM_LOG_ERR, NOM_DUMP
# and friends), run the test's executable directly. This debugging output will
# not be shown when using the 'test' target -- i.e.: make target.
#
# IMPORTANT: Compiling nomlib under Windows without iterator asserts --
# /D_ITERATOR_DEBUG_LEVEL=0 -- will cause GTest to throw SEH exception errors
# before it is able to display actual & expected results when a unit test fails.
#
# NOTE: The custom command line processing used by nom::UnitTest for interactive
# interactive test runs breaks under Windows when building with the target
# library ${GTEST_BOTH_LIBRARIES}, due to GTest's main library overwriting our
# unit test's main functions. In summary, only the library target
# ${GTEST_LIBRARY} should be used, to ensure cross-platform support.

# Source file inclusion root (directory); must be an absolute path.
set( TESTS_SRC_DIR "${PROJECT_SOURCE_DIR}/tests/src" )
Expand Down Expand Up @@ -132,8 +118,6 @@ endif( NOT EXISTS ${TCLAP_INCLUDE_DIR} )
include_directories("${NOM_THIRD_PARTY_COMMON_DIR}")

# Unit test dependencies (common / global)
#
# NOTE: We prefer linking to GTest statically.
if( PLATFORM_OSX )
set( GTEST_ROOT "${NOMLIB_DEPS_DIR}/osx/gtest" )
else( PLATFORM_WINDOWS )
Expand Down Expand Up @@ -251,14 +235,24 @@ endif( NOM_BUILD_SERIALIZERS_TESTS )
# Install library dependencies into tests output directory so we can always
# execute the binaries with the proper dependency versions.
if ( PLATFORM_WINDOWS )

if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set( GTEST_LIBRARY_REDIST_DLL "${GTEST_ROOT}/lib/gtestd.dll" )
else()
set( GTEST_LIBRARY_REDIST_DLL "${GTEST_ROOT}/lib/gtest.dll" )
endif()

install( FILES ${GTEST_LIBRARY_REDIST_DLL}
DESTINATION ${TESTS_INSTALL_DIR}
RENAME "gtest.dll" )

install ( DIRECTORY
${SDL2_REDIST_DIR}
${SDL2_IMAGE_REDIST_DIR}
${SDL2_TTF_REDIST_DIR}
${OPENAL_REDIST_DIR}
${LIBSNDFILE_REDIST_DIR}
${MSVCPP_REDIST_DIR}
"${GTEST_ROOT}/lib/" # GTest re-dist libs
DESTINATION
${TESTS_INSTALL_DIR}
FILES_MATCHING PATTERN "*.dll"
Expand Down
13 changes: 12 additions & 1 deletion third-party/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,20 @@ Both the 64-bit and 32-bit official development binaries versions of:
- Packaged only for Windows
* [Google Test v1.7.0](https://code.google.com/p/googletest/) built with:
```
```console
# Debug library
mkdir build-debug && cd build-debug
cmake -DBUILD_SHARED_LIBS=on ..
msbuild /t:build gtest.vcxproj
msbuild /t:build gtest_main.vcxproj
```
```console
# Release library
mkdir build-release && cd build-release
cmake -DBUILD_SHARED_LIBS=on -DCMAKE_BUILD_TYPE=Release ..
msbuild /t:build gtest.vcxproj /p:Configuration=Release
msbuild /t:build gtest_main.vcxproj /p:Configuration=Release
```
* [libsndfile v1.0.25](http://www.mega-nerd.com/libsndfile/)
Expand Down

0 comments on commit c7fdf2f

Please sign in to comment.