[CMake] Setting the C dialect

Brad King brad.king at kitware.com
Wed Nov 1 12:49:26 EST 2006


Filipe Sousa wrote:
> Mattias Holm wrote:
>> Hi there,
>>
>> I am new to the list, so excuse me if this has been asked before.
>>
>> I am trying to figure out if there is a good way of setting the  
>> language dialect that you are using. For example, I am working with a  
>> project written in C99, and thus I need to specify this.
>>
>> Sure enough, I can use SET_SOURCE_FILES_PROPERTIES and set the  
>> compile flags for every C-file to -std=c99/gnu99 and at least that  
>> will work with GCC. Is there any way to do this portably, and without  
>> setting the compile flags on every source file?
> 
> 
> IF(CMAKE_COMPILER_IS_GNUCC)
>   SET(CMAKE_C_FLAGS -std=c99)
> ENDIF()

The set should be

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

-Brad


More information about the CMake mailing list