指定CMAKE构建32位/64位版本的程序

  • GCC (on Linux) and some other compilers, e.g Sun Studio. Set CFLAGS and CXXFLAGS to include -m32 (32-bit build) or -m64 (64-bit build).

  • Windows, Visual Studio generator .Use 64 bit generator ,e.g

    cmake -G "Visual Studio 10 Win64" path\to\source\dir

    to compile 64-bit (x64). Omit "Win64" in generator name, to build for 32 bit

  • Mac OS X. Use CMAKE_OSX_ARCHITECTURES CMake variable.

    cmake -DCMAKE_OSX_ARCHITECTURES=i386 /path/to/source/dir will compile 32 bit build

    cmake -DCMAKE_OSX_ARCHITECTURES=x86_64 /path/to/source/dir will compile 64 bit.

    Finally, cmake "-DCMAKE_OSX_ARCHITECTURES=x86_64;i386" /path/to/source/dir will create 96-bit universal binaries :)

posted @ 2013-08-06 11:36  NesTa.xP  阅读(12365)  评论(0)    收藏  举报