[cmake-developers] [CMake 0012300]: CMake has no cross-platform way to ask for C99
Mantis Bug Tracker
mantis at public.kitware.com
Wed Jun 22 16:49:09 EDT 2011
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=12300
======================================================================
Reported By: Todd Gamblin
Assigned To:
======================================================================
Project: CMake
Issue ID: 12300
Category: CMake
Reproducibility: always
Severity: feature
Priority: high
Status: new
======================================================================
Date Submitted: 2011-06-22 16:49 EDT
Last Modified: 2011-06-22 16:49 EDT
======================================================================
Summary: CMake has no cross-platform way to ask for C99
Description:
There 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 Reproduce:
1. Start a project
2. Try to enable C99 without a giant multi-compiler if/else statement
3. Fail
Additional Information:
Related email thread citing a need for this in VTK to eliminate warnings:
http://www.cmake.org/pipermail/cmake/2011-June/045072.html
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2011-06-22 16:49 Todd Gamblin New Issue
======================================================================
More information about the cmake-developers
mailing list