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

Alexander Neundorf a.neundorf-work at gmx.net
Fri Apr 25 13:17:47 EDT 2008


On Friday 25 April 2008, Christoph Cullmann wrote:
> 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.

Setting the CC, CXX, CFLAGS and CXXFLAGS environment variables when cmake is 
run initially should work.
Is this good enough ?

Alex


More information about the CMake mailing list