Added option to configure static vs shared MSVC runtime · SRombauts/SQLiteCpp@521181c (original) (raw)

Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
15 15 message (STATUS "CMake version: ${CMAKE_VERSION}")
16 16 message (STATUS "Project version: ${PROJECT_VERSION}")
17 17
18 +option(SQLITECPP_USE_STATIC_RUNTIME "Use MSVC static runtime (default for internal googletest)." ON)
19 +
18 20 # Define useful variables to handle OS differences:
19 21 if (WIN32)
20 22 set(DEV_NULL "NUL")
@@ -28,14 +30,14 @@ if (MSVC)
28 30 set(CPPCHECK_ARG_TEMPLATE "--template=vs")
29 31 # disable Visual Studio warnings for fopen() used in the example
30 32 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
31 -# Flags for linking with multithread static C++ runtime, required by googletest
32 - if (SQLITECPP_BUILD_TESTS)
33 - message(STATUS "Linking against multithread static C++ runtime for unit tests with googletest")
33 +# Flags for linking with multithread static C++ runtime, required by internal googletest
34 + if (SQLITECPP_USE_STATIC_RUNTIME)
35 + message(STATUS "Linking against multithread static C++ runtime")
34 36 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
35 37 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
36 38 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
37 39 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
38 - endif (SQLITECPP_BUILD_TESTS)
40 + endif (SQLITECPP_USE_STATIC_RUNTIME)
39 41 # MSVC versions prior to 2015 are not supported anymore by SQLiteC++ 3.x
40 42 if (MSVC_VERSION LESS 1900) # OR MSVC_TOOLSET_VERSION LESS 140)
41 43 message(ERROR "Visual Studio prior to 2015 is not supported anymore.")