How to detect if 64 bit MSVC with cmake?

后端 未结 7 1588
既然无缘
既然无缘 2020-12-09 08:42

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()

7条回答
  •  时光说笑
    2020-12-09 09:17

    The usual way to check if you're generating for a 64 bits architecture is to test CMAKE_SIZEOF_VOID_P:

    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
        # 64 bits
    elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
        # 32 bits
    endif()
    

提交回复
热议问题