lundi, juin 24, 2013

CMake : Compiling for different hardware architectures


  • GCC (on Linux) or Sun Studio
Use compile option -m32 (force 32-bit build), -m64 (force 64-bit build)
  • Windows, Visual Studio generator
Use cmake -G "Visual Studio 9 2008 Win64" path_to_source_dir to compile 64-bit (x64)
  • Mac OS X
Use CMAKE_OSX_ARCHITECTURES CMake variable. You can set more than a single architecture to create universal binary, e.g
 cmake "-DCMAKE_OSX_ARCHITECTURES=i386;pcc" path_to_source 
will build universal binary with 32-bit intel / 32-bit powerpc.
cmake "-DCMAKE_OSX_ARCHITECTURES=x86_64" path_to_source 
will create x86_64 binary.

  • NMake Makefiles
    for 64 bits use the right SetEnv ou vsvarsall.bat command line and then
    cmake path to source -G "NMake Makefiles"
    nmake

Aucun commentaire: