[CMake] Overriding C compiler flags in CMakeLists files

Michael Wild themiwi at gmail.com
Tue Aug 9 10:32:58 EDT 2011


On Tue 09 Aug 2011 04:28:51 PM CEST, Tim Gallagher wrote:
> In your leaf CMakeLists.txt, try doing:
> 
> set_source_files_properties(${SOURCE_FILES} PROPERTIES COMPILE_FLAGS
> ${LOCAL_COMPILE_FLAGS})
> 
> where ${SOURCE_FILES} is a list of the files in the directory and
> ${LOCAL_COMPILE_FLAGS} is the list of flags for those files.
> 
> Ideally you would want to set this for the entire directory, but
> according to the documentation, the COMPILE_FLAGS property doesn't exist
> for directories.
> 
> Tim
>

Setting a directory property wouldn't help, since the directory 
property is inherited by the target, not the source files. And since 
the target lives in the top-level CMakeLists.txt file, the directory 
properties wouldn't come into play at all.

Michael


More information about the CMake mailing list