MantisBT - CMake
View Issue Details
0012633CMakeCMakepublic2011-12-18 14:112012-09-03 16:01
hrogge 
Brad King 
normalmajoralways
closedfixed 
CMake 2.8.6 
CMake 2.8.8CMake 2.8.8 
0012633: GCC fails some flags with "is valid for C++/ObjC++ but not for C"
GCC has some flags that are valid for C++, but not for C. The different warning message breaks the CHECK_C_COMPILER_FLAG macro.

Suggestion: add
  'FAIL_REGEX "but not for C" # GNU'

to CheckCCompilerFlag.cmake
compile "int main(void) { return 0 };" on gcc 4.4.5 with -Wenum-compare:

/usr/bin/gcc -Wenum-compare -o test.o -c test.c
cc1: warning: command line option "-Wenum-compare" is valid for C++/ObjC++ but not for C
Combined with ADD_DEFINITIONS(-Werror) this can break the build process. The CheckCCompilerFlag does not recognize that -Wenum-compare is not available, -Werror stops the build process.
No tags attached.
Issue History
2011-12-18 14:11hroggeNew Issue
2011-12-19 10:55Brad KingNote Added: 0028009
2011-12-19 23:21Sean McBrideNote Added: 0028015
2011-12-21 14:50hroggeNote Added: 0028029
2011-12-22 09:42Brad KingNote Added: 0028035
2011-12-22 09:42Brad KingStatusnew => resolved
2011-12-22 09:42Brad KingResolutionopen => fixed
2011-12-22 09:42Brad KingAssigned To => Brad King
2012-04-19 15:42David ColeFixed in Version => CMake 2.8.8
2012-04-19 15:42David ColeTarget Version => CMake 2.8.8
2012-09-03 16:01David ColeNote Added: 0030868
2012-09-03 16:01David ColeStatusresolved => closed

Notes
(0028009)
Brad King   
2011-12-19 10:55   
The regex added in

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

doesn't match?
(0028015)
Sean McBride   
2011-12-19 23:21   
Not exactly related, but I'm very much reminded of bug 0004756.
(0028029)
hrogge   
2011-12-21 14:50   
Ahh, I just noticed I was using 2.8.5 on one of the machines. The error does only happen in 2.8.6 when you use "-Werror" together with the other option, because the start of the output will change from "warning" to "error".

But testing two options at once was more an experiment to learn what was going on than a good usage.

Sorry for making that much noise.

Maybe it would be a good idea to completely remove the "warning:" part from the regex (and replace the "# Apple gcc" comment with "# gcc", because it can also happens on Linux).
(0028035)
Brad King   
2011-12-22 09:42   
Good ideas, thanks:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=646cf919 [^]
(0030868)
David Cole   
2012-09-03 16:01   
Closing resolved issues that have not been updated in more than 4 months.