View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010837CMakeModulespublic2010-06-16 10:112016-02-07 15:35
ReporterFrancois Kritzinger 
Assigned ToGregor Jasny 
PrioritynormalSeveritytextReproducibilityalways
StatusclosedResolutionduplicate 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionFixed in VersionCMake 3.6 
Summary0010837: GCC flag -isystem not applied on OS X
DescriptionI've seen it mentioned in places (e.g. http://public.kitware.com/Bug/view.php?id=4462 [^]) that GCC on OS X doesn't support -isystem, but I can confirm that GCC 4.2.1 on OS X 2.6.4 does indeed support it.

For this reason I recommend that the following code at the bottom of Modules/Compiler/GNU.cmake

  if(NOT APPLE)
      set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
  endif(NOT APPLE)

be changed to

  set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")

(the reverse of the patch attached to the above-mentioned bug report).

TagsNo tags attached.
Attached Files

 Relationships
related to 0004462closedBrad King Do not use -isystem on Mac OS X 
related to 0015687closedGregor Jasny target_include_directories(): SYSTEM option does not seem to work when targeting Xcode. 
related to 0015953closedGregor Jasny CMake Does Not Use -isystem with GCC on OS X 

  Notes
(0024481)
Bill Hoffman (manager)
2011-01-06 16:14

Is this still an issue?
(0024508)
Francois Kritzinger (reporter)
2011-01-07 13:41

I think it is indeed still an issue, as the change I suggested has not been made in HEAD. Unless I am missing something?

One obvious thing I left out above was a check for the version of GCC and OS X. I couldn't say when -isystem support was first added, but, as I said above, I can confirm that it is supported on GCC 4.2.1 on OS X 10.6, which I am quite certain is the version of GCC it ships with.
(0024519)
Brad King (manager)
2011-01-07 16:53

I see -isystem documented in a very old Apple GCC:

  gcc version 3.3 20030304 (Apple Computer, Inc. build 1666)
  ProductName: Mac OS X
  ProductVersion: 10.3.9
  BuildVersion: 7W98

I think reverting the change from 0004462 is reasonable. If the original problem in that bug is really an issue then it needs to be investigated in more detail to show why -isystem is broken.
(0027206)
Grant Limberg (reporter)
2011-08-15 19:12

isystem definitely works on Apple GCC and Clang compilers today.

If i recall correctly, it didn't work correctly with g++ on Tiger, though. I ran into a situation at a previous employer where attempting to compile a C++ project that used -isystem flags on OS X 10.4. g++ on Tiger implicitly added an an extern "C" around all includes that were found in the -isystem path. This was fixed as of Leopard, though.
(0028781)
Andrew Hill (reporter)
2012-03-01 22:57

I've tried removing the "if(NOT APPLE)" guards but this doesn't seem to help (Xcode 4.3)

Xcode 4.3 uses llvm/clang, but as far as I can tell CMake still treats this as GNU?
Have also modded Modules/Platform/Darwin.cmake (which currently clears CMAKE_INCLUDE_SYSTEM_FLAG_C and CMAKE_INCLUDE_SYSTEM_FLAG_CXX) but this also had no effect on the commands being called by Xcode.

clang and gcc that come with Xcode 4.3 both support -isystem, but I can't seem to get cmake/xcode to put it in the command line that it builds with, and can't seem to see which is at fault
(0029911)
Strahinja Markovic (reporter)
2012-07-05 00:36
edited on: 2012-07-05 00:43

I am experiencing this issue as well, even in the latest version (CMake 2.8.8). This problem basically kills the "SYSTEM" option to include_directories(). So if I use include_directories(SYSTEM <some path to header>) on Mac OS X, the SYSTEM option is completely ignored and cmake uses -I flags instead of -isystem (verified by looking at the generated flags.make file). With -Werror, this breaks my builds on Macs (because of warnings coming from irrelevant headers).

As noted, using set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") before the include_directories(SYSTEM ...) call is a good workaround that resolves the problem.

Clang accepts -isystem just fine as does the Apple flavor of GCC.

This seems easily fixable: removing the if(NOT APPLE) condition should suffice. Any chance of seeing this change in trunk soon?

Note: I'm using the Unix Makefiles generator, Mac OS X Lion and "Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)"

(0032099)
valentin (reporter)
2013-01-13 09:18
edited on: 2013-01-16 19:13

I currently need to use the -isystem flag to turn off some warnings in 3rd party headers, and I confirm that Xcode support -isystem flag too.

Is it possible, in addition to the proposed patch which make -isystem flag understandable by Unix Makefiles generator, to replace

IF(XCODE)
  SET(CMAKE_INCLUDE_SYSTEM_FLAG_C)
  SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX)
ENDIF(XCODE)

by something like

IF(XCODE)
  set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
ENDIF(XCODE)

in Modules/Platform/Darwin.cmake and Modules/Platform/Darwin-icc.cmake too?
(and maybe in QNX.cmake if it support this flag too)

EDIT : QNX seems to support it too ==> http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/g/gcc.html [^]

EDIT2 : I don't know the internal use for the 3 last .cmake files, but maybe it is better to completely remove this condition if GNU.cmake is included before them.

(0040443)
Gregor Jasny (developer)
2016-02-07 15:34

CMake will turn on -isystem for GCC >= 4 on Apple systems. See 0015953 for follow-ups.

 Issue History
Date Modified Username Field Change
2010-06-16 10:11 Francois Kritzinger New Issue
2011-01-06 16:14 Bill Hoffman Note Added: 0024481
2011-01-06 16:15 Bill Hoffman Assigned To => Bill Hoffman
2011-01-06 16:15 Bill Hoffman Status new => assigned
2011-01-07 13:41 Francois Kritzinger Note Added: 0024508
2011-01-07 16:49 Brad King Relationship added related to 0004462
2011-01-07 16:53 Brad King Note Added: 0024519
2011-08-15 19:12 Grant Limberg Note Added: 0027206
2012-03-01 22:57 Andrew Hill Note Added: 0028781
2012-07-05 00:36 Strahinja Markovic Note Added: 0029911
2012-07-05 00:38 Strahinja Markovic Note Edited: 0029911
2012-07-05 00:43 Strahinja Markovic Note Edited: 0029911
2013-01-13 09:18 valentin Note Added: 0032099
2013-01-13 09:19 valentin Note Edited: 0032099
2013-01-13 09:21 valentin Note Edited: 0032099
2013-01-16 19:13 valentin Note Edited: 0032099
2015-08-07 04:41 Gregor Jasny Relationship added related to 0015687
2016-02-07 07:47 Gregor Jasny Assigned To Bill Hoffman => Gregor Jasny
2016-02-07 07:47 Gregor Jasny Relationship added related to 0015953
2016-02-07 15:34 Gregor Jasny Note Added: 0040443
2016-02-07 15:35 Gregor Jasny Status assigned => closed
2016-02-07 15:35 Gregor Jasny Resolution open => duplicate
2016-02-07 15:35 Gregor Jasny Fixed in Version => CMake 3.6


Copyright © 2000 - 2018 MantisBT Team