[CMake] Overriding CMAKE_C_FLAGS on a per-directory basis

Marcel Loose loose at astron.nl
Fri Jan 8 11:04:00 EST 2010


Hi Ingolf,

If you've set the flags "-foo -bar" using add_definitions(), instead of
manipulating CMAKE_C_FLAGS directly, you can use 

  set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "-baz")

to override the compile definitions for the current directory and its
subdirectories.

Hope this helps,
Marcel Loose.

On Fri, 2010-01-08 at 12:26 +0100, Ingolf Steinbach wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake




More information about the CMake mailing list