cmake: Build gtest and benchmark as shared lib with MSVC

should fix `gmock.lib(gtest-all.obj) : error LNK2005`
This commit is contained in:
Corentin Le Molgat
2025-01-31 16:21:05 +01:00
committed by Mizux Seiha
parent de4180fb6d
commit befa5f7a4f

View File

@@ -413,14 +413,7 @@ if(BUILD_googletest)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF)
set(GTEST_HAS_ABSL ON)
if(WIN32)
set(BUILD_SHARED_LIBS OFF)
endif()
FetchContent_MakeAvailable(googletest)
if(WIN32)
set(BUILD_SHARED_LIBS ON)
endif()
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
@@ -438,13 +431,7 @@ if(BUILD_benchmark)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_WERROR OFF)
set(BENCHMARK_ENABLE_INSTALL OFF)
if(WIN32)
set(BUILD_SHARED_LIBS OFF)
endif()
FetchContent_MakeAvailable(benchmark)
if(WIN32)
set(BUILD_SHARED_LIBS ON)
endif()
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()