Skip to content

Commit

Permalink
Don't set SQLITECPP_USE_STATIC_RUNTIME by default when building with …
Browse files Browse the repository at this point in the history
…unit tests

Use gtest_force_shared_crt to force googletest to link against the default dynamic C++ runtime
  • Loading branch information
SRombauts committed Aug 17, 2023
1 parent c682a0b commit 997c930
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ if (MSVC)
# 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})
option(SQLITECPP_USE_STATIC_RUNTIME "Use MSVC static runtime (default for internal googletest)." FALSE)
if (SQLITECPP_USE_STATIC_RUNTIME)
message(STATUS "Linking against multithread static C++ runtime")
# inspired from Zlib licensed glfw https://github.com/glfw/glfw/blob/master/CMakeLists.txt
foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
Expand All @@ -55,6 +55,11 @@ if (MSVC)
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")

endforeach()
else (SQLITECPP_USE_STATIC_RUNTIME)
if (SQLITECPP_BUILD_TESTS)
message(STATUS "Force googletest to link against dynamic C++ runtime")
set(gtest_force_shared_crt ON CACHE BOOL "Use shared (DLL) run-time lib even when Google Test is built as static lib.")
endif (SQLITECPP_BUILD_TESTS)
endif (SQLITECPP_USE_STATIC_RUNTIME)
# MSVC versions prior to 2015 are not supported anymore by SQLiteC++ 3.x
if (MSVC_VERSION LESS 1900) # OR MSVC_TOOLSET_VERSION LESS 140)
Expand Down

0 comments on commit 997c930

Please sign in to comment.