summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-08-22 14:15:23 -0400
committerBrad King <brad.king@kitware.com>2019-08-23 10:55:58 -0400
commited54d877894499319d67628b730053484e97049c (patch)
treec3ed617efd305a6802e4d429cf06c305ceea5dd7 /CMakeLists.txt
parent130dbe4a5d49baa4404a399860bd3a6182783ece (diff)
downloadcmake-ed54d877894499319d67628b730053484e97049c.tar.gz
Configure CMake itself with policies through CMake 3.15
In particular, set `CMP0091` to `NEW` to enable the MSVC runtime library abstraction so it can be set via `CMAKE_MSVC_RUNTIME_LIBRARY` in the cache.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt13
1 files changed, 12 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e3d39de8c..aa8a4c7454 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,13 +1,24 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-cmake_minimum_required(VERSION 3.1...3.14 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.1...3.15 FATAL_ERROR)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake)
project(CMake)
unset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C)
+# FIXME: This block should go away after a transition period.
+if(MSVC AND NOT CMAKE_VERSION VERSION_LESS 3.15)
+ # Filter out MSVC runtime library flags that may have come from
+ # the cache of an existing build tree or from scripts.
+ foreach(l C CXX)
+ foreach(c DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
+ string(REGEX REPLACE "[-/]M[DT]d?( |$)" "" "CMAKE_${l}_FLAGS_${c}" "${CMAKE_${l}_FLAGS_${c}}")
+ endforeach()
+ endforeach()
+endif()
+
# Make sure we can find internal find_package modules only used for
# building CMake and not for shipping externally
list(INSERT CMAKE_MODULE_PATH 0 ${CMake_SOURCE_DIR}/Source/Modules)