[CMake] Overriding C compiler flags in CMakeLists files

Tim Gallagher tim.gallagher at gatech.edu
Tue Aug 9 10:36:18 EDT 2011


Interesting -- I guess this is sort of off topic from the original post, but that brings up a question:

How does setting the COMPILE_DEFINITIONS on the directory work then? I was under the impression (not having tried it) that those definitions would only be added when compiling files contained in the directory. I assumed COMPILE_FLAGS could, if it existed, operate the same way. 

Tim

----- Original Message -----
From: "Michael Wild" <themiwi at gmail.com>
To: cmake at cmake.org
Sent: Tuesday, August 9, 2011 10:32:58 AM
Subject: Re: [CMake] Overriding C compiler flags in CMakeLists files

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
_______________________________________________
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