From 658dbfc68e4ec324afed391b2c57168a5c6a2481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Thu, 17 Aug 2023 16:27:21 +0200 Subject: [PATCH] Remove SQLITECPP_USE_STATIC_RUNTIME altogether Use gtest_force_shared_crt to force googletest to link against the default dynamic C++ runtime --- CMakeLists.txt | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 886c68f0..52bac69c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,27 +35,14 @@ if (MSVC) set(CPPCHECK_ARG_TEMPLATE "--template=vs") # disable Visual Studio warnings for fopen() used in the example add_definitions(-D_CRT_SECURE_NO_WARNINGS) - # Flags for linking with multithread static C++ runtime, required by internal googletest - # inspired from Zlib licensed glfw https://github.com/glfw/glfw/blob/master/CMakeLists.txt - option(SQLITECPP_USE_STATIC_RUNTIME "Use MSVC static runtime (default for internal googletest)." ${SQLITECPP_BUILD_TESTS}) - if (SQLITECPP_USE_STATIC_RUNTIME) - message(STATUS "Linking against multithread static C++ runtime") - foreach (flag CMAKE_C_FLAGS - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS - CMAKE_CXX_FLAGS_DEBUG - CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS_RELWITHDEBINFO) - - string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}") - string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") - - endforeach() - endif (SQLITECPP_USE_STATIC_RUNTIME) + + # Flags for linking with MSVC C++ runtime when using googletest + if (SQLITECPP_BUILD_TESTS) + # Use shared (DLL) run-time lib even when Google Test is built as static lib. + set(gtest_force_shared_crt ON) + message(STATUS "Force googletest to link against dynamic C++ runtime") + endif (SQLITECPP_BUILD_TESTS) + # MSVC versions prior to 2015 are not supported anymore by SQLiteC++ 3.x if (MSVC_VERSION LESS 1900) # OR MSVC_TOOLSET_VERSION LESS 140) message(ERROR "Visual Studio prior to 2015 is not supported anymore.")