On 06/26/2011 04:12 PM, Owen Shepherd wrote:
> On 25/06/2011 07:30, "Michael Hertling" <mhertl...@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.

This would require to configure the entire project *before* the compiler
is chosen, and this means that constructs like

IF(CMAKE_C_COMPILER_ID STREQUAL ...)

or

IF(CMAKE_COMPILER_IS_GNUC)

wouldn't work anymore. Of course, they're quite useful and necessary if
one wants to enable compiler-specific features, so the compiler must be
chosen at the very beginning. Moreover, IMO, it's absolutely inevitable
that the responsibility for choosing a suitable compiler rests on the
user. The fact that CMake usually finds a suitable one automatically
- although common and very convenient - should be considered as the
exception rather than the rule, at least in multi-compiler setups.

Regards,

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

Reply via email to