[CMake] Overriding C compiler flags in CMakeLists files
Michael Wild
themiwi at gmail.com
Tue Aug 9 10:43:01 EDT 2011
Well, directory properties are used by _targets_ defined in that
directory. It doesn't matter where the sources are located.
Michael
On 08/09/2011 04:36 PM, Tim Gallagher wrote:
> 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
More information about the CMake
mailing list