6

I'm searching for way to set Target Platform Version of MSVC project generated with CMake. I found the following ticket in CMake issue tracker which is now closed. I'm with latest 3.9.1 version of CMake. But the solution described there seems to not work. I tried

set (CMAKE_SYSTEM_VERSION 8.1)

in my CMakeLists.txt.

How to set Terget Platform Version when using CMake?

Afterwords:

Now I checked that setting CMAKE_SYSTEM_VERSION from command line when generating solution works but I want if possible to be able to set this from CMakeLists.txt file.

cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_SYSTEM_VERSION=8.1 ..\source\

At least it will be good to be able to set this from CMake GUI.

bobeff
  • 3,543
  • 3
  • 34
  • 62
  • 1
    Have a look at the -T command line option of CMake. (e.g. `-T v120` or `-T v141`) . See this answer for further information https://stackoverflow.com/questions/35549164/how-cmake-specify-platform-toolset-for-a-visual-studio-2015-project – vre Aug 15 '17 at 12:31
  • Never mind, I mixed up Target Platform Version and Target Platform Toolset. – vre Aug 15 '17 at 13:23
  • 2
    You can set this in GUI. You just click the button "Add Entry". Beware that a full version string, like it appears in "Windows SDK Version" property page in VS must be entered. For me worked with: CMAKE_SYSTEM_VERSION = 10.0.17763.0 – Emil Mocan Mar 28 '19 at 03:54
  • Must add this entry before click 'Configure'. – kbridge4096 Aug 15 '19 at 13:19

1 Answers1

7

Using set (CMAKE_SYSTEM_VERSION 8.1 CACHE TYPE INTERNAL FORCE) before first usage of project solves the problem.

bobeff
  • 3,543
  • 3
  • 34
  • 62
  • Note that it must be before the first `project` of your *top-level* `CMakeLists.txt`, since it needs to be set globally at generation time (obvious, but I missed it). – BTJ Dec 07 '18 at 00:32