[CMake] C standard and order of arguments

Magnus Therning magnus at therning.org
Tue Jan 12 05:45:37 EST 2016


I'm trying to turn on a bit more warnings in a C project but I'm running
into an ordering issue.

I have

#+BEGIN_SRC cmake
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "-Wall -Wextra -Werror")
#+END_SRC

and I want to add ~-Wpedantic~. However if I do then I get a lot of warnings
(that are turned into errors) about breaking C99. In particular:

#+BEGIN_QUOTE
ISO C99 requires at least one argument for the "..." in a variadic macro [-Werror]
#+END_QUOTE

This apparently comes from ~-std=gnu11~ (the result of setting
~CMAKE_C_STANDARD~) appearing /after/ the other flags. If I change my
~CMakeLists.txt~ to instead contain

#+BEGIN_SRC cmake
set(CMAKE_C_FLAGS "-std=gnu11 -Wall -Wextra -Wpedantic -Werror")
#+END_SRC

Then I don't get those C99-related warnings. Is there some way to get
~CMAKE_C_STANDARD~ to put ~-std=gnu11~ /before/ the other flags?

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: magnus at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus

LeBlanc's law: Later equals never.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160112/df1e4f6d/attachment.sig>


More information about the CMake mailing list