[CMake] Overriding CMAKE_C_FLAGS on a per-directory basis

Ingolf Steinbach ingolf.steinbach at googlemail.com
Fri Jan 8 06:26:00 EST 2010


Hi,

is it possible to override CMAKE_C_FLAGS on a per-directory basis? I
have attempted to solve this by setting CMAKE_C_FLAGS to a different
value than the default used in the project, but this modification is
not reflected in the command line for compilation within the
directory. Example

"global" CMAKE_C_FLAGS are "-foo -bar"

some_dir/CMakeLists.txt:
[...]
set(CMAKE_C_FLAGS "-argl")
[...]

Still sources in some_dir are compiled with "-foo -bar" rather than
with "-argl".


Also setting the COMPILE_FLAGS property via
set_source_files_properties() applied to the sources in some_dir would
only *append* the new flags to "-foo -bar" rather than replacing them.

cmake 2.8 on Linux.

Kind regards
Ingolf


More information about the CMake mailing list