[CMake] Find out current CXX_FLAGS at build time?
Zachary Pincus
zpincus at stanford.edu
Wed Feb 15 09:52:04 EST 2006
> CMAKE_C_FLAGS_DEBUG will be used in the Debug configuration of the
> IDE.
So here's the issue:
I want to add a custom command that (at build time) gets fed the same
flags as the compiler.
Say I do the following (modulo errors):
ADD_CUSTOM_COMMAND(
SOURCE ${input_cxx}
COMMAND ${GCCXML}
ARGS -gccxml-cxxflags<${CMAKE_CXX_FLAGS_DEBUG}>
...
)
This gets expanded at configure time to whatever the contents of that
variable are. Specifically, the debug flags are selected, even if the
build type isn't debug.
Say I got more clever and tried:
ARGS -gccxml-cxxflags<${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}>
This would work fine for makefile targets, where the BUILD_TYPE
variable is set at configure time, so the variables would all be
expanded before build time.
However, with an IDE, the user can select the build type at build
time, so none of the above games would work, because everything above
expands at configure time.
I guess that I could, at configure time, write n different files
(one for each configuration_type), and then pass gcc_xml the correct
file (via CMAKE_CFG_INTDR variable that does expand properly at
build time). My query was whether there was an accessible configure-
time variable that expands (at configure time) to a variable that
expands (at build time) to the current set of CXX_FLAGS. Presumably
cmake knows about the latter variable (the build-time one) because it
must be set differently for each configuration type.
The question then is whether cmake makes the name of that variable
available in a configure-time variable. The model for this is
CMAKE_CFG_INTDIR, which does this double-expansion trick to provide
the proper intdir variable for whatever IDE is driving the build.
Zach
More information about the CMake
mailing list