Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ CMake检查Windows版本_C++_Windows 7_Windows 8_Visual Studio 2012_Cmake - Fatal编程技术网

C++ CMake检查Windows版本

C++ CMake检查Windows版本,c++,windows-7,windows-8,visual-studio-2012,cmake,C++,Windows 7,Windows 8,Visual Studio 2012,Cmake,如何向CMake检查我是否正在为Windows 7或Windows 8配置Visual Studio解决方案 有什么方法可以做到这一点吗?您可以使用CMAKE\u系统\u名称和CMAKE\u系统\u版本 ## Check for Windows ## if( WIN32 ) # true if windows (32 and 64 bit) ## Check for Version ## if( ${CMAKE_SYSTEM_VERSION} EQUAL 6.1 ) # Win

如何向CMake检查我是否正在为Windows 7或Windows 8配置Visual Studio解决方案


有什么方法可以做到这一点吗?

您可以使用
CMAKE\u系统\u名称
CMAKE\u系统\u版本

## Check for Windows ##
if( WIN32 ) # true if windows (32 and 64 bit)

    ## Check for Version ##
    if( ${CMAKE_SYSTEM_VERSION} EQUAL 6.1 ) # Windows 7
        # Do something here
    elseif( ${CMAKE_SYSTEM_VERSION} EQUAL 6.2 ) # Windows 8
        # Do something here
    else() # Some other Windows
        # Do something here
    endif()

endif()

您可以使用
execute\u process
和execute
ver
来获取验证。这不会给出cmake正在运行的版本而不是目标系统吗?不,它返回您正在编译的系统的版本。我猜您的意思是
CMAKE_VERSION
-此变量指定CMAKE可执行文件的版本。