[CMake] how to make cmake filter the environments' CXXFLAG, and use that filtered string for the build types of choice?

Stefan Kögl skoegl at online.de
Fri Mar 14 08:15:50 EDT 2008


hi to all,

I'm using cmake under linux for a c++ project.
I want / have to filter out gcc CXXFLAGS provided by the environment.

Supposed a user of my trunk wants to compile my software, and sets  some nice 
flags my program will not like at runtime:

export CXXFLAGS="-march=prescott -O6 -fguess-not-calc -fbork-me-completely"

I'm only interested in the -march or -mtune flag, so I could do something 
like:

SET(RAW_FLAGS $ENV{CXXFLAGS})
STRING(REGEX MATCH "[-]march=.*[ ]|[-]mtune=.*[ ]" result "${RAW_FLAGS}" )
MESSAGE("${result}")

Ok, now I have a something to work with, but how can I make cmake to ignore 
the $ENV{CXXFLAGS} for predefined and/or custom build types?

Thank you in advance,

Sk


More information about the CMake mailing list