[CMake] Enabling C99 in CMake

Owen Shepherd owen.shepherd at e43.eu
Sun Jun 26 10:12:50 EDT 2011


On 25/06/2011 07:30, "Michael Hertling" <mhertling at online.de> wrote:

>On 06/24/2011 04:16 PM, Owen Shepherd wrote:
>> I think the appropriate solution here is a project-specific dialect
>>flag -
>> perhaps one taking options in the GNU format since it seems most
>>familiar.
>> One could perhaps generalise this further - a file-specific dialect flag
>> which defaults to the value of the project-specific flag
>
>If there are individual compilers for C89/C99, and a projects needs a
>C99 one, any dialect flags - project/directory/target/file specific -
>would be of no use, wouldn't they? Rather, one must specify the C99
>compiler if it isn't found automatically by CMake during the initial
>configuration, and the project might consider to check the compiler's
>C99 capabilities.

Sorry - I should have said property rather than flag. That is, something
along the lines of
	set_target_properties(the_target PROPERTIES C_DIALECT C99)
Or
	set_source_files_properties(myfile.c PROPERTIES C_DIALECT C99)

(I'm not entirely sure here whether the source file property should be
C_DIALECT or just DIALECT. The language, after all, should be unambiguous
at this point)

It would then be the responsibility of the Cmake machinery to choose the
right compiler and set it up for building code with the given dialect.

-- Owen Shepherd
http://www.owenshepherd.net
owen.shepherd at e43.eu (general) / oshepherd1 at shef.ac.uk (academic)






More information about the CMake mailing list