[CMake] How to dictate cmake best CFLAGS/...

Christoph Cullmann cullmann at absint.com
Fri Apr 25 10:25:12 EDT 2008


Hi,

we have a strict set of C/CXX/LDFLAGS we want to pass the toolchain per 
default, how can that be accomplished best with cmake? Before, we just used 
nmake with handcrafted files using some environment variables.

I tried to call cmake on windows like:

"\"$WINPREFIX\\bin\\cmake\" \
    -DCMAKE_ROOT_WIN:PATH=\"$CMAKE_ROOT_WIN\" \
    -DCMAKE_INSTALL_PREFIX:PATH=\"$CMAKE_INSTALL_PREFIX_WIN\" \
    -DCMAKE_C_FLAGS:STRING=\"$CMAKE_C_FLAGS_WIN\" \
    -DCMAKE_CXX_FLAGS:STRING=\"$CMAKE_CXX_FLAGS_WIN\" \
    -DCMAKE_C_LINK_FLAGS:STRING=\"$CMAKE_C_LINK_FLAGS_WIN\" \
    -DCMAKE_CXX_LINK_FLAGS:STRING=\"$CMAKE_CXX_LINK_FLAGS_WIN\" \
    -G \"$CMAKE_GENERATOR_WIN\""

(with the vars being our stuff), but unlike on linux, where this allows me to 
overwrite the standard flags, on windows still for a later normal nmake run 
the default "Debug" flags are used.

Any good way to accomplish this task in a sane way without too much hassle?
The important stuff I must overwrite is the used compiler (only on linux, that 
works nice with C_COMPILER + CXX_COMPILER) and the flags for compilers + 
linker.

cu
Christoph

-- 
-------------------------------------- Christoph Cullmann ---------
AbsInt Angewandte Informatik GmbH      Email: cullmann at AbsInt.com
Science Park 1                         Tel:   +49-681-38360-22
66123 Saarbrücken                      Fax:   +49-681-38360-20
GERMANY                                WWW:   http://www.AbsInt.com
--------------------------------------------------------------------
Geschäftsführung: Dr.-Ing. Christian Ferdinand
Eingetragen im Handelsregister des Amtsgerichts Saarbrücken, HRB 11234


More information about the CMake mailing list