[cmake-developers] C|CXX Standards Handling

Daniel Wirtz daniel.wirtz at simtech.uni-stuttgart.de
Wed Sep 16 03:56:28 EDT 2015


Hello CMake Developers,

i've recently encountered an issue with the CMake [CMAKE_]C_STANDARD 
settings. (same for CXX)
For initial background see 
http://public.kitware.com/pipermail/cmake/2015-September/061546.html

Basically, CMake silently continues to configure past any 
set(CMAKE_C_STANDARD <value>) command even if CMake does
not have any information on the necessary flags for the current compiler.
In my case, i've had that issue with the SUPERLU_DIST package and Intel 
14.xx compilers.
The configure stage would go fine but the compile breaks complaining 
about all sorts of weird things, from
which it was far from obvious it was because of the missing -std=c99 
flag. Especially as i've entrusted CMake to
handle that situation as i've also specified 
set(CMAKE_C_STANDARD_REQUIRED YES).

I know there's standard flags information right now only for gnu and 
clang, and having them included for all
supported compilers will be a different issue. but i suggest to include 
the following into cmake:

- if there is no standards information for the given compiler, issue a 
warning to tell the developer just that.
- if additionally XX_REQUIRED is set on cmake or target level, throw a 
fatal error on configure time as cmake cannot ensure
   to set the correct flags required for the requested C standard.

of course, this wont save the user the trouble of finding the correct 
flags for the current compiler for himself, but at least
it's a more informed action than just wondering why suddenly everything 
breaks which went fine on GNU.

this will clearly be redundant once all supported compilers have the 
necessary information, but would also
makes cmake more robust in case new compilers come in without having the 
standards info contained at the beginning.

Cheers
Daniel

-- 
Dr. Daniel Wirtz
Dipl. Math. Dipl. Inf.
SRC SimTech
Pfaffenwaldring 5a
+49 711 685 60044



More information about the cmake-developers mailing list