File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,9 +45,6 @@ if (NOT ("${GOOGLE_CLOUD_CPP_CXX_STANDARD}" STREQUAL ""))
4545 "GOOGLE_CLOUD_CPP_CXX_STANDARD is retired, use CMAKE_CXX_STANDARD" )
4646endif ()
4747
48- list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake)
49- include (SelectMSVCRuntime )
50-
5148if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" )
5249
5350 # gcc-4.8 is the first release that claims C++11 support.
@@ -68,8 +65,20 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
6865 " either lack C++11 support or have bugs that prevent us from"
6966 " using them." )
7067 endif ()
68+ elseif ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "MSVC" )
69+
70+ if (CMAKE_VERSION VERSION_LESS 3.15)
71+ message (
72+ FATAL_ERROR
73+ "MSVC builds require CMake >= 3.15."
74+ " Previous versions of CMake lack a standard mechanism to"
75+ " select the runtime C++ library." )
76+ endif ()
7177endif ()
7278
79+ list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake)
80+ include (SelectMSVCRuntime )
81+
7382option (GOOGLE_CLOUD_CPP_ENABLE_MACOS_OPENSSL_CHECK
7483 "If enabled, check that the user has defined OPENSSL_ROOT_DIR on macOS"
7584 ON )
Original file line number Diff line number Diff line change 2929#
3030
3131if (MSVC )
32- # TODO(#5852) - if we require CMake >= 3.15 we can remove this conditional
33- # and the hacks below.
34- if (NOT (CMAKE_VERSION VERSION_LESS 3.15))
35- if (VCPKG_TARGET_TRIPLET MATCHES "-static$" )
36- set (CMAKE_MSVC_RUNTIME_LIBRARY
37- "MultiThreaded$<$<CONFIG :Debug >:Debug >" )
38- else ()
39- set (CMAKE_MSVC_RUNTIME_LIBRARY
40- "MultiThreaded$<$<CONFIG :Debug >:Debug >DLL" )
41- endif ()
42- elseif (VCPKG_TARGET_TRIPLET MATCHES "-static$" )
43- message (
44- WARNING
45- [===[
46- CMake is too old to use CMAKE_MSVC_RUNTIME_LIBRARY.
47- Attempting to set CMAKE_CXX_FLAGS* to get consistent CRT versions.
48- ]===] )
49- foreach (flag_var
50- CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
51- CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO )
52- if (${flag_var} MATCHES "/MD" )
53- string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var} }" )
54- endif ()
55- endforeach (flag_var )
56- unset (flag_var)
32+ if (VCPKG_TARGET_TRIPLET MATCHES "-static$" )
33+ set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG :Debug >:Debug >" )
34+ else ()
35+ set (CMAKE_MSVC_RUNTIME_LIBRARY
36+ "MultiThreaded$<$<CONFIG :Debug >:Debug >DLL" )
5737 endif ()
5838endif ()
You can’t perform that action at this time.
0 commit comments