From 3d3b8f257a96aaaea1ea00cc55903fc21758bccc Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Mon, 16 Jul 2018 12:48:56 +0200 Subject: [PATCH] Adding warning --- chapters/basics.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/chapters/basics.md b/chapters/basics.md index 29028d3..ef27b76 100644 --- a/chapters/basics.md +++ b/chapters/basics.md @@ -22,12 +22,24 @@ This is what new projects should do: cmake_minimum_required(VERSION 3.1...3.11) if(${CMAKE_VERSION} VERSION_LESS 3.12) - cmake_policy(VERSION ${CMAKE_VERSION}) + cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) endif() ``` If CMake version is less than 3.12, the if block will be true, and the policy will be set to the current CMake version. If CMake is 3.12 or higher, the if block will be false, but the new syntax in `cmake_minimum_required` will be respected and this will continue to work properly! +WARNING: MSVC's CMake [seems to have a bug](https://github.com/fmtlib/fmt/issues/809) in reading this format, so if you need to support non-command line Windows builds, you will want to do this instead: + +```cmake +cmake_minimum_required(VERSION 3.1) + +if(${CMAKE_VERSION} VERSION_LESS 3.11) + cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +else() + cmake_policy(VERSION 3.11) +endif() +``` + {% hint style='info' %} If you really need to set to a low value here, you can use «command:`cmake_policy`» to conditionally increase the policy level or set a specific policy. Please at least do this for your macOS users!