VS: 3.27.0-rc2 does not set WindowsTargetPlatformVersion with arch in generator name
3.27.0-rc2 does not set WindowsTargetPlatformVersion when using Visual Studio generator.
Citing from CMP0149 description:
CMake 3.27 and higher prefer to ignore the exact value of CMAKE_SYSTEM_VERSION and by default select the latest SDK version available.
(emphasis my own)
I assume SDK version referred to is "Windows SDK Version" (rather than eg. toolset version). However, when generating build directory using Visual Studio 2017 generator, WindowsTargetPlatformVersion
element is not generated in .vcxproj
file. Visual Studio then uses default value of "Windows SDK Version", which is 8.1, even though I have newer Windows SDKs installed. I have tried to use
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION 10.0.19041.0)
to force minimum Windows SDK version, but that seems to generate an element WindowsTargetPlatformMinVersion
in .vcxproj
that is ignored by Visual Studio 2017 (not sure whether newer ones understand it).
It also appears that setting the policy behavior to OLD does not have any effect on this.
Tested using very simple project.
main.cpp
#include <cstdio>
int main(int argc, char** argv)
{
printf("Hello world\n");
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.27.0 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION 10.0.19041.0)
project(BugReport VERSION 0.1.0 LANGUAGES CXX)
add_executable(test main.cpp)