Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 03dff03

Browse files
meastpg-easy
authored andcommitted
Add gtest_force_shared_crt for MSVC (#284)
This fixes linking with MSVC.
1 parent a90406a commit 03dff03

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmake/OpenCensusDeps.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ if(BUILD_TESTING)
1616
if(NOT TARGET gtest_main)
1717
message(STATUS "Dependency: googletest (BUILD_TESTING=${BUILD_TESTING})")
1818

19+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
20+
# All the libraries in the build must use either /MD or /MT (runtime
21+
# library to link)
22+
#
23+
# force this option to ON so that Google Test will use /MD instead of /MT
24+
# /MD is now the default for Visual Studio, so it should be our default,
25+
# too
26+
option(
27+
gtest_force_shared_crt
28+
"Use shared (DLL) run-time lib even when Google Test is built as static lib."
29+
ON)
30+
endif()
31+
1932
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/googletest.CMakeLists.txt
2033
${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt)
2134
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .

0 commit comments

Comments
 (0)