CMake检查Windows版本(CMake check Windows version)

编程入门 行业动态 更新时间:2024-10-27 02:24:42
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()

更多推荐

本文发布于:2023-08-05 05:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428641.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   Windows   CMake   check   version

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!