VS: 2017/2019 generator ignoring target Windows Version
Unlike the VC14 generator the VS 2017,2019 generator seems to ignore the Target Windows Version. Take this call in cmake 3.17.1 on a Windows 7 host:
cmake -G "Visual Studio 16 2019" -DCMAKE_GENERATOR="Visual Studio 16 2019" -A x64 -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_BUILD_TYPE:STRING="Release" -DCMAKE_SYSTEM=Windows-10.0.18362 -DCMAKE_SYSTEM_VERSION=10.0.18362 -DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=10.0 -DCMAKE_SYSTEM_NAME=Windows
It is meant to target Windows 10 but gives this output
-- The C compiler identification is MSVC 19.27.29112.0
-- The CXX compiler identification is MSVC 19.27.29112.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
**-- Selecting Windows SDK version 8.1 to target Windows 6.1.7601.**
The same command for -G "Visual Studio 14 Win64" -DCMAKE_GENERATOR="Visual Studio 14 Win64"
-- Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.18362.
-- The C compiler identification is MSVC 19.0.24210.0
-- The CXX compiler identification is MSVC 19.0.24210.0
-- Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.18362.