MantisBT - CMake
View Issue Details
0015953CMakeCMakepublic2016-02-04 03:142016-06-10 14:21
jbauer 
Gregor Jasny 
normalminoralways
closedfixed 
AppleOS X10.11.3
CMake 3.4.3 
CMake 3.6CMake 3.6 
0015953: CMake Does Not Use -isystem with GCC on OS X
On OS X with the GCC compiler, CMake does not pass the -isystem flag to build commands for libraries configured with SYSTEM. For example, if target 'cmake_test' has an include added as 'target_include_directories( cmake_test SYSTEM PRIVATE ${PNG_INCLUDE_DIRS} )', -isystem will not be added on OS X with GCC.
Use the 'target_include_directories' command with the SYSTEM option on OS X with GCC.

A minimal project that reproduces this issue has been provided via:
https://github.com/digitalriptide/cmake_test [^]
No tags attached.
related to 0004462closed Brad King Do not use -isystem on Mac OS X 
related to 0010837closed Gregor Jasny GCC flag -isystem not applied on OS X 
Issue History
2016-02-04 03:14jbauerNew Issue
2016-02-04 08:24Brad KingNote Added: 0040438
2016-02-04 08:41Gregor JasnyAssigned To => Gregor Jasny
2016-02-04 08:41Gregor JasnyStatusnew => assigned
2016-02-07 07:18Gregor JasnyRelationship addedrelated to 0004462
2016-02-07 07:47Gregor JasnyRelationship addedrelated to 0010837
2016-02-07 14:45Gregor JasnyNote Added: 0040442
2016-02-09 10:11Brad KingNote Added: 0040448
2016-02-09 10:11Brad KingStatusassigned => resolved
2016-02-09 10:11Brad KingResolutionopen => fixed
2016-02-09 10:11Brad KingFixed in Version => CMake 3.6
2016-02-09 10:11Brad KingTarget Version => CMake 3.6
2016-06-10 14:21Kitware RobotNote Added: 0041264
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040438)
Brad King   
2016-02-04 08:24   
This is due to a condition here:

 https://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Compiler/GNU.cmake;hb=v3.4.3#l55 [^]

 if(NOT APPLE)
   set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
 endif()

which is present because at one time gcc on Apple did not support the flag. The condition may need to be updated to check the version/vendor of gcc.
(0040442)
Gregor Jasny   
2016-02-07 14:45   
I pushed apple-isystem-gcc topic containing
https://cmake.org/gitweb?p=stage/cmake.git;a=commit;h=2cae5128fdc6316a7f0913cb89ec467b33b9715b [^]

This will be available with CMake 3.6. In the meatime you could work around by adding something like this to your root CMakeLists.txt:
if(APPLE)
  set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
  set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
endif()
(0040448)
Brad King   
2016-02-09 10:11   
Re 0015953:0040442: Thanks. The commit is now in 'master':

 Apple: Enable -isystem for GNU Compiler >= 4
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2cae5128 [^]
(0041264)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.