<div class="gmail_quote">On Fri, Apr 3, 2009 at 9:16 AM, Óscar Fuentes <span dir="ltr"><<a href="mailto:ofv@wanadoo.es">ofv@wanadoo.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have this:<br>
<br>
add_custom_command(OUTPUT ${LLVM_CONFIG}<br>
COMMAND echo "flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS}"<br>
.... more stuff ....<br>
<br>
<br>
When the custom command executes, this is the output:<br>
<br>
flags:<br>
<br>
i.e. the variables are empty, although I previously used add_definitions<br>
to add flags and the makefile uses the optimization flags that<br>
corresponds to the selected build type.<br>
<br>
How can I access the effective values of the flags used when the<br>
makefile is generated?</blockquote><div><br>Hi Oscar,<br><br>CMAKE_CXX_FLAGS / CMAKE_C_FLAGS is empty by default on Linux unless you've modified it which may have been what happened. The build type specific complilation flags are stored in CMAKE_CXX_FLAGS_<config_type>. CMAKE_CXX_FLAGS is a base that gets prepended to all of the build solutions.<br>
<br>The command pasted below works for me on CMake 2.6.4 RC3 Win32 using
the MinGW generator (it outputs the flags used to compile during a Release build). If something like this doesn't work for you can you reply with
your version of CMake and generator you're using?<br><br>add_custom_target(foo COMMAND C:/cygwin/bin/echo.exe flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})<br><br>Also, to possibly anticipate your next question: On Makefile generators you should be able to get the current build type being used by the end user by referencing CMAKE_BUILD_TYPE. Note that empty is a supported build type in which case only CMAKE_CXX_FLAGS would be used. On multi-solution generators like for Visual Studio you won't be able to tell the CMAKE_BUILD_TYPE at configure time so you'd pretty much have to just pick one or more configuration types to output.<br>
<br>HTH<br clear="all"></div></div><br>-- <br>Philip Lowman<br>