Skip to content

Commit

Permalink
Test: [skip ci] fix linking errors of Google tests with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 2, 2022
1 parent 3148ea6 commit f6cf0e7
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tests/CMakeLists.txt
@@ -1,6 +1,37 @@
# 'Google_test' is the subproject name
project(Google_tests)

if(WIN32)
add_definitions(-DCOIN_DLL)
endif(WIN32)

if(MSVC)
option(
gtest_force_shared_crt
"Use shared (DLL) run-time lib even when Google Test is built as static lib."
ON)

set(Google_Tests_LIBS
oldnames.lib
debug msvcrtd.lib
debug msvcprtd.lib
optimized msvcrt.lib
optimized msvcprt.lib
)

#Universal C runtime introduced in VS 2015 (cl version 19)
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19"))
list(APPEND Google_Tests_LIBS
debug vcruntimed.lib
debug ucrtd.lib
debug concrtd.lib
optimized vcruntime.lib
optimized ucrt.lib
optimized concrt.lib
)
endif()
endif()

# 'lib' is the folder with Google Test sources
add_subdirectory(lib)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
Expand All @@ -14,7 +45,7 @@ add_executable(
src/test2.cpp
)

target_link_libraries(Google_Tests_run gtest gtest_main)
target_link_libraries(Google_Tests_run gtest gtest_main ${Google_Tests_LIBS})

# ------------------------------------------------------

Expand Down

0 comments on commit f6cf0e7

Please sign in to comment.