cmake 编译 32/64位

linux:

方法一(选项):option(USE_32BITS "Compile for 32bits processors(linux only)" OFF)

方法二(命令):CMake .. -DUSE_32BITS=1  (可以写到make_solution.sh 中)

CMakelist.txt: 

if(USE_32BITS)
 message(STATUS "using 32bits")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")

 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")

else()
endif(USE_32BITS)


windows:

以下可以写到make_solution.bat中

x86: 

@echo off
::
:: Run this batch file to create Visual studio solution file for this project.
:: Seet the cmake documentation for other generator targets
::
cmake -G "Visual Studio 10" ../.. && cmake-gui ../..


x64:

@echo off
::
:: Run this batch file to create Visual studio solution file for this project.
:: Seet the cmake documentation for other generator targets
::
cmake -G "Visual Studio 10 Win64" ../.. && cmake-gui ../..

你可能感兴趣的:(cmake)