[CMake] -D constants

Alexander Neundorf a.neundorf-work at gmx.net
Mon Mar 31 16:34:40 EDT 2008


On Monday 31 March 2008, stephan ripke wrote:
> Hello,
> I am a cmake-beginner and I want to "translate" my old project for use with
> cmake:
> 1) I brought some constants with the preprocessor from the Makefile into my
> sourcecode (e.g.: g++ -Dconstant=10 main.cpp). How do I do something like
> this with cmake?

add_definitions(-Dfoo)

or better create a config.h which contains all that (using configure_file()).

> 2) Are there constants like "Windows" "Unix" "Linux", so
> the compiling of my project could react depending on the system?

Yes.
You can use the variable CMAKE_SYSTEM_NAME or test the short versions WIN32, 
UNIX and APPLE. In the cmake wiki (www.cmake.org -> developers -> wiki) there 
is a page "useful variables" which lists them.

Alex


More information about the CMake mailing list