本文介绍了如何使用cmake检测64位MSVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用cmake的项目,一个目标设置为仅使用MSVC构建:

I have a project which uses cmake, one target is set to only build with MSVC:

 if (MSVC)
     add_library(test SHARED source.cpp)
 endif()

现在,另一个问题是该目标仅适用于32位MSVC.那么如何检测生成器为MSVC64并跳过此目标?

Now the other issue is that this target is only designed for MSVC 32bit. So how can I detect that the generator is MSVC64 and skip this target?

推荐答案

CMake本身也使用几种方法来检查不是64位":

There are several ways - also used by CMake itself - that will check for "not 64Bit":

if(NOT "${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
    ...
endif()

if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
    ...
endif()

if(NOT CMAKE_CL_64)
   ...
endif()

参考

这篇关于如何使用cmake检测64位MSVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 19:24