[CMake] Per-target compiler flags?

Brandon J. Van Every bvanevery at gmail.com
Wed Jul 5 13:20:19 EDT 2006


Jan Woetzel wrote:
> Remi Denis-Courmont wrote:
>
>> The project is compiling the same source files multiple times with 
>> different
>> defines, resulting in different object code... But it seems like
>> ADD_DEFINITIONS won't support this case.
>>
>> Any solution?
>>
>>  
>>
>
> You may write multiple .cpp files that #include the code.
> Then use SET_SOURCE_FILES_PROPERTIES with different PROPERTIES 
> COMPILE_FLAGS for each file.
>
> Work great, here.

I myself use SET_TARGET_PROPERTIES to send flags to all .c files in my 
specific target.


SET_TARGET_PROPERTIES(libchicken PROPERTIES
  COMPILE_FLAGS "-DC_BUILDING_LIBCHICKEN ${SHARED_FLAGS}"
)

SET_TARGET_PROPERTIES(libuchicken-static PROPERTIES
  COMPILE_FLAGS "-DC_BUILDING_LIBCHICKEN -DC_UNSAFE_RUNTIME ${STATIC_FLAGS}"
)



Cheers,
Brandon Van Every



More information about the CMake mailing list