diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b7da898d1d..8babd66af75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0. # -cmake_minimum_required(VERSION 3.13 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15 FATAL_ERROR) option(LEGACY_BUILD "If enabled, the SDK will use 1.11.0 version of CMake files to build" ON) if (LEGACY_BUILD) @@ -16,6 +16,7 @@ if (LEGACY_BUILD) if (POLICY CMP0077) cmake_policy(SET CMP0077 OLD) # CMP0077: option() honors normal variables. Introduced in 3.13 endif () + cmake_policy(SET CMP0091 NEW) get_filename_component(AWS_NATIVE_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) @@ -147,6 +148,12 @@ if (LEGACY_BUILD) else () set(STATIC_CRT ON) endif () + + if (${STATIC_CRT}) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + else () + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + endif () # Add Linker search paths to RPATH so as to fix the problem where some linkers can't find cross-compiled dependent libraries in customer paths when linking executables. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true) diff --git a/cmake/compiler_settings.cmake b/cmake/compiler_settings.cmake index a7689dc5955..6f0fe118df3 100644 --- a/cmake/compiler_settings.cmake +++ b/cmake/compiler_settings.cmake @@ -75,18 +75,6 @@ endmacro() macro(set_msvc_flags) if(MSVC) - # Based on the FORCE_SHARED_CRT and BUILD_SHARED_LIBS options, make sure our compile/link flags bring in the right CRT library - # modified from gtest's version; while only the else clause is actually necessary, do both for completeness/future-proofing - foreach (var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if(BUILD_SHARED_LIBS OR FORCE_SHARED_CRT) - string(REPLACE "/MT" "/MD" ${var} "${${var}}") - else() - string(REPLACE "/MD" "/MT" ${var} "${${var}}") - endif() - endforeach() - # enable parallel builds set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # some of the clients are exceeding the 16-bit code section limit when building x64 debug, so use /bigobj when we build