How to set MSVC Target Platform Version with CMake?

北战南征 提交于 2021-02-07 20:30:55

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/45692367/how-to-set-msvc-target-platform-version-with-cmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!