[CMake] compiler options per platform

Rolf Eike Beer eike at sf-mail.de
Thu Nov 4 10:42:10 EDT 2010


> Hi,
>
> Best practice:
> I have no yet realized how to set compiler options per platform.
>
>
> -          Ensuring that "rtti" is enabled on Windows, Linux and Solaris.
>
> -          Ensuring that "exceptions" are enabled on Windows, Linux and
> Solaris.
>
> -          Setting the default compilers (on one Solaris machine I did
> have GNU
> and the cc/CC compilers and cmake took GNU but I want to have cc/CC.
> Of course I know how to use another on the command line but I would
> prefer to set this as a "default" for each Solaris system.
>
> -          How to tell best to make 32 bit / 64 bit builds for Windows,
> Linux and Solaris?
> Also a 32 bit build should be possible on a 64 bit machine.

If you are building using MSVC this is rather easy: you need to either
start CMake from a compiler shell (Start -> Programs -> Microsoft Visual
Studio Tools -> xxx command prompt) and use "NMake Makefiles" (or "..
JOM"), or if you want to build using the IDE just set the proper generator
(e.g. "Visual Studio 9 2008" vs. "Visual Studio 9 2008 Win64").

For Unix systems this is just setting CC and CXX environment variables or
specifying them on the CMake command line. Also you may want to have a
look on the CMakeForceCompiler macro (also I don't think this is what you
want in this case).

Eike



More information about the CMake mailing list