How to detect if 64 bit MSVC with cmake?

后端 未结 7 1650
既然无缘
既然无缘 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:12

    This example worked for me on cmake 3.17.0:

    if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64")
      ....
    endif()
    
    if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")
      ...
    endif()
    

提交回复
热议问题