CMake检查Windows版本(CMake check Windows version)
如何查看CMake我是否正在为Windows 7或Windows 8配置Visual Studio解决方案?
有没有办法做到这一点?
How do I check with CMake whether I'm configuring a Visual Studio solution for Windows 7 or Windows 8?
Is there a way to do this?
最满意答案
您可以使用CMAKE_SYSTEM_NAME和CMAKE_SYSTEM_VERSION
## 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()You can use CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_VERSION
## 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()更多推荐
发布评论