MantisBT - CMake
View Issue Details
0012258CMakeCMakepublic2011-06-09 00:422011-11-11 10:45
Campbell Barton 
Brad King 
normalminoralways
closedfixed 
x86-64linuxarch/latest
 
CMake 2.8.5CMake 2.8.5 
0012258: include_directories(SYSTEM ...) not functional with GNU Makefiles
There were some system headers giving warnings compiling on linux,
since I like to have warnings as errors, and not edit system headers,
I used:
 include_directories(SYSTEM dir1 dir2 ...)
... for system directories only.

However this does not result in -isystem being used in C because
GNU.cmake does not set:
 set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
... as it does for C++.

I tried adding this directly after the project(), call (beforehand it
fails to have any effect):

       if(CMAKE_COMPILER_IS_GNUCC)
               if(NOT APPLE)
                       set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
               endif()
       endif()


So now it almost works, but I've noticed that If
"include_directories(SYSTEM" is called after a non system include, ALL
includes then use -isystem.

Putting "include_directories(SYSTEM" first mostly works out OK, but I
found a few cases where the order isn't so easy to set in our own
CMakeLists.txt and still incorrectly uses -isystem where it shouldn't.
Also found using the BEFORE / AFTER arguments to include_directories(
doesn't make any difference to the use of -isystem.

Is this a known problem or is there a way to get this working?
No tags attached.
Issue History
2011-06-09 00:42Campbell BartonNew Issue
2011-06-11 05:48Campbell BartonNote Added: 0026829
2011-06-13 17:52Brad KingAssigned To => Brad King
2011-06-13 17:52Brad KingStatusnew => assigned
2011-06-13 17:57Brad KingNote Added: 0026851
2011-06-13 17:57Brad KingStatusassigned => resolved
2011-06-13 17:57Brad KingResolutionopen => fixed
2011-06-18 07:46David ColeFixed in Version => CMake 2.8.5
2011-06-18 07:46David ColeTarget Version => CMake 2.8.5
2011-11-11 10:45David ColeNote Added: 0027773
2011-11-11 10:45David ColeStatusresolved => closed

Notes
(0026829)
Campbell Barton   
2011-06-11 05:48   
Update, ignore the order of calling include_directories(SYSTEM / include_directories(, this was an error on my part.

So the only problem is with CMAKE_INCLUDE_SYSTEM_FLAG_C not being set

According to Michael Hertling, GNU.cmake
 set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")

should be replaced with.
 set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
(0026851)
Brad King   
2011-06-13 17:57   
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33f5a83a [^]
(0027773)
David Cole   
2011-11-11 10:45   
Closing resolved issues that have not been updated in more than 4 months.