Test: [skip ci] fix linking errors of Google tests with MSVC
This commit is contained in:
@@ -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})
|
||||
@@ -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})
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user