[CMake] Enabling C99 in CMake

Rolf Eike Beer eike at sf-mail.de
Sat Jun 25 06:16:03 EDT 2011


Am Samstag, 25. Juni 2011, 08:30:21 schrieb Michael Hertling:
> On 06/23/2011 06:20 PM, Jed Brown wrote:
> > On Thu, Jun 23, 2011 at 17:50, Michael Hertling <mhertling at online.de> 
wrote:
> >> You need to use a C99 compiler for your project
> > 
> > This is already a problem. C99 introduces new keywords (e.g. restrict)
> > and removes implicit int. It is entirely possible for part of a project
> > to include C89-conforming legacy code that is not valid C99. The use of
> > C99 or C89 should be a file- and directory-level property.
> 
> That's a really good point and could indeed be very well addressed by
> a possibility for a project to enable language dialects per directory/
> target/file as Todd has asked for in his initial posting. In order to
> achieve this in a platform/compiler-independent manner, take a look at
> the attached dialects.patch file, a diff against the Modules directory
> of CMake 2.8.4. It is not meant as a production-ready solution, but as
> as proof of concept, and it's restricted to the GNU C compiler, though
> it should be easily applicable to the other compilers known by CMake.
> 
> First of all, the new Compiler/LanguageDialects.cmake file provides a
> function __language_dialects() which accepts a language and a paired
> list of arguments denoting each supported language dialect followed by
> the flags to enable it. The function sets up the variable CMAKE_<LANG>_
> DIALECTS_INIT containing the list of dialects, and for each dialect a
> variable CMAKE_<LANG>_DIALECT_<DIALECT>_INIT containing the respective
> flags. The Compiler/GNU-C.cmake file is enhanced to - exemplary - call
> 
> > __language_dialects(C C90 "-std=c90" C89 "-std=c89" C99 "-std=c99" C9X
> > "-std=c9x" C1X "-std=c1x" ANSI "-ansi")

I like that. Even more as this would easily add the possibility to get C++0x 
support switching using the very same way.

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110625/ee2497c5/attachment.pgp>


More information about the CMake mailing list