[CMake] Different CMAKE_CXX_FLAGS for different executables

David Doria daviddoria at gmail.com
Thu Mar 24 10:44:22 EDT 2011


Is there a way to explicitly set the CMAKE_CXX_FLAGS for a particular
executable? That is, if I set CMAKE_CXX_FLAGS and then have a
add_executable line, then change CMAKE_CXX_FLAGS and then have another
add_executable, will the first set of CMAKE_CXX_FLAGS be applied to
the first executable and the second set of CMAKE_CXX_FLAGS be applied
to the second executable?

I guess my confusion is that I don't understand how CMake variables are cached.

Each time I modify the variable, should I do it using

SET(CMAKE_CXX_FLAGS "some flags")

or

SET(CMAKE_CXX_FLAGS "some flags" CACHE STRING "compiler flags")

?

In this example: http://codepad.org/PGJRBjss the messages are actually
not displayed at all, which is only adding to my confusion :)

Any comments on this?

Thanks,

David


More information about the CMake mailing list