View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012300CMakeCMakepublic2011-06-22 16:492014-11-03 08:38
ReporterTodd Gamblin 
Assigned ToStephen Kelly 
PriorityhighSeverityfeatureReproducibilityalways
StatusclosedResolutionfixed 
PlatformAllOSAllOS VersionAll
Product VersionCMake 2.8.4 
Target VersionFixed in VersionCMake 3.1 
Summary0012300: CMake has no cross-platform way to ask for C99
DescriptionThere is currently no good cross-platform way in CMake to specify that C files should be built for C99.

If you google for this, there are threads on the CMake list that suggest this:

    set(CMAKE_C_FLAGS "-std=c99")

However, that's the GNU way to enable C99, and other compilers do it differently. It would be nice if there were some flags for this set for you in whatever platform file you're using, e.g.:

    set(CMAKE_C_FLAGS "${CMAKE_ENABLE_C99}")

Or something to that effect. Then you'd pick up -qlanglvl=c99 for xlc, -std=c99 for gcc, etc.

Would it be reasonable to add this to platform files? CMAKE_SYSTEM_C99_FLAGS or something similar?

Note: for GNU there is std=c99 *and* std=gnu99, and one might need a way to prefer the latter. std=c99 is strict, and doesn't allow things (like inline asm) that other compilers allow in c99 mode. I'm not sure what the best way to get consistent behavior here would be. I would need to look at flags on some of the major compilers to figure this one out.

Should this be a variable or something else? A language mode seems like overkill (e.g. enable_language(C99)).
Steps To Reproduce1. Start a project
2. Try to enable C99 without a giant multi-compiler if/else statement
3. Fail
Additional InformationRelated email thread citing a need for this in VTK to eliminate warnings:

http://www.cmake.org/pipermail/cmake/2011-June/045072.html [^]
TagsNo tags attached.
Attached Files

 Relationships
related to 0013842closedStephen Kelly No Support for C++11 

  Notes
(0027605)
Olaf Lenz (reporter)
2011-10-21 08:33

I want to second.
(0027606)
Sean McBride (reporter)
2011-10-21 09:44

The same need exists for C++. Any given .cxx file may be C++98, C++03, or C++11. Each very similar to the other, but none entirely compatible.
(0030366)
David Cole (manager)
2012-08-11 21:09

Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0032618)
Ian Liu Rodrigues (reporter)
2013-03-13 17:10

I've made a very simple solution to this, by looking into Automake's code. It tries to compile a C program containing a number of C99 features.

Here is the example: https://gist.github.com/ianliu/5156223 [^]

I hope this can be of some use. Should the GPL notice become a problem tell me so I can change it.
(0035958)
Stephen Kelly (developer)
2014-05-28 15:57

The implementation of the 'compile features' concept is now in master:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ca5d990f [^] [^]

which includes several ways of requiring or optionally using C99 or C11 features. There are gaps in the compiler support matrix, but the functionality is in, and extending the compiler support can be recorded with other bug reports.
(0037148)
Robert Maynard (manager)
2014-11-03 08:38

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2011-06-22 16:49 Todd Gamblin New Issue
2011-10-21 08:33 Olaf Lenz Note Added: 0027605
2011-10-21 09:44 Sean McBride Note Added: 0027606
2012-08-11 21:09 David Cole Status new => backlog
2012-08-11 21:09 David Cole Note Added: 0030366
2013-03-13 17:10 Ian Liu Rodrigues Note Added: 0032618
2013-11-02 11:34 Stephen Kelly Relationship added related to 0013842
2014-05-28 15:57 Stephen Kelly Assigned To => Stephen Kelly
2014-05-28 15:57 Stephen Kelly Status backlog => assigned
2014-05-28 15:57 Stephen Kelly Note Added: 0035958
2014-05-28 15:57 Stephen Kelly Status assigned => resolved
2014-05-28 15:57 Stephen Kelly Fixed in Version => CMake 3.1
2014-05-28 15:57 Stephen Kelly Resolution open => fixed
2014-11-03 08:38 Robert Maynard Note Added: 0037148
2014-11-03 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team