How to get HEADER_SEARCH_PATHS to produce -isystem

2019-07-15 10:44发布

问题:

I want to suppress warnings in the headers we include from third party libraries. According to what I've read here and elsewhere (e.g., Set system search path in Xcode 4), by putting the appropriate path in the HEADER_SEARCH_PATHS variable of the .pbxproj file, it should result in clang using a -isystem command line option instead of -I, thus suppressing warnings.

However, it's not working. As you can see from the snippet of the .pbx file below, we're setting the include paths using that variable, but the clang command is using -I. Is there something else I need to be doing to get it to work?

Compile line generated:

   CompileC /Users/stebro/build_xcode/daemon/ClientEngine/Services.build/Debug/ClientEngine.build/Objects-normal/i386/Register.o legacy/Client/Library/LibEngine/Register.cpp normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/stebro/daemon
    setenv LANG en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
     -x c++
     -arch i386
     -fmessage-length=0
     -fdiagnostics-show-note-include-stack
     -fmacro-backtrace-limit=0
     -Wno-trigraphs
     -fpascal-strings
     -O0
     -Wno-missing-field-initializers
     -Wno-missing-prototypes
     -Wno-return-type
     -Wno-non-virtual-dtor
     -Wno-overloaded-virtual
     -Wno-exit-time-destructors
     -Wno-missing-braces
     -Wparentheses
     -Wswitch
     -Wno-unused-function
     -Wno-unused-label
     -Wno-unused-parameter
     -Wno-unused-variable
     -Wunused-value
     -Wno-empty-body
     -Wno-uninitialized
     -Wno-unknown-pragmas
     -Wno-shadow
     -Wno-four-char-constants
     -Wno-conversion
     -Wno-constant-conversion
     -Wno-int-conversion
     -Wno-bool-conversion
     -Wno-enum-conversion
     -Wshorten-64-to-32
     -Wno-newline-eof
     -Wno-c++11-extensions
     -DCMAKE_INTDIR=\"Debug\"
     -DPRODVER_STRING=\"99.9.9d1\ build\ 999\ (2008-01-01\ 12:00:00)\"
     -DPRODVER_FULL=\"99.9.999\"
     -DPRODVER_MAJOR=99
     -DPRODVER_MINOR=9
     -DPRODVER_BUILD_NO=999
     -DQT_CORE_LIB
     -DASSERT_ON
     -DQT_DEBUG
     -D_DEBUG=1
     -isysroot /Applications/Xcode\ 4.6.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
     -fasm-blocks
     -fstrict-aliasing
     -Wdeprecated-declarations
     -Winvalid-offsetof
     -mmacosx-version-min=10.6
     -g
     -Wno-sign-conversion
     -I/Users/stebro/build_xcode/daemon/ClientEngine/Debug/include
     -I/Volumes/ToolChain/include
     -I/Volumes/ToolChain/qt-4.8/include
     -I/Volumes/ToolChain/qt-4.8/lib/QtCore.framework/Headers
     -I/Users/stebro/daemon/legacy/Client/Library/LibEngine/../../include
     -I/Users/stebro/build_xcode/daemon/ClientEngine
     -I/Users/stebro/daemon/legacy/Shared/Common/../include
     -I/Users/stebro/daemon/legacy/Shared/Common
     -I/Users/stebro/daemon/legacy/Client/Mac/MSDEV
     -I/Users/stebro/daemon/legacy/Client/Mac/MSDEV/mac/include
     -I/Users/stebro/daemon/legacy/Client/Mac/MSDEV/INCLUDE
     -I/Users/stebro/daemon/legacy/Client/Mac/Common
     -I/Users/stebro/daemon/legacy/Client/3rdParty/jsoncpp/include
     -I/Users/stebro/build_xcode/daemon/ClientEngine/Services.build/Debug/ClientEngine.build/DerivedSources/i386
     -I/Users/stebro/build_xcode/daemon/ClientEngine/Services.build/Debug/ClientEngine.build/DerivedSources
     -Wmost
     -Wno-four-char-constants
     -Wno-unknown-pragmas
     -F/Users/stebro/build_xcode/daemon/ClientEngine/Debug
     -F/Volumes/ToolChain/qt-4.8/lib
     -Werror
     -Wno-c++11-extensions
     -Wno-c99-extensions
     -Wno-c++98-compat
     -Wno-#warnings
     -include /var/folders/bv/5qmzyrw94_lbq7qpql9pykr4fm0g52/C/com.apple.DeveloperTools/5.0.2-5A3005/Xcode/SharedPrecompiledHeaders/Engine_pch-bsdymkkefyenxegggqlsprjbexjx/Engine_pch.h
     -MMD
     -MT dependencies
     -MF /Users/stebro/build_xcode/daemon/ClientEngine/Services.build/Debug/ClientEngine.build/Objects-normal/i386/Register.d
     --serialize-diagnostics /Users/stebro/build_xcode/daemon/ClientEngine/Services.build/Debug/ClientEngine.build/Objects-normal/i386/Register.dia
     -c /Users/stebro/daemon/legacy/Client/Library/LibEngine/Register.cpp
     -o /Users/stebro/build_xcode/daemon/ClientEngine/Services.build/Debug/ClientEngine.build/Objects-normal/i386/Register.o

Relevant .pbxproj sections:

              F73E14C1508B4E9F9713949A /* Debug */ = {
                     isa = XCBuildConfiguration;
                     buildSettings = {
                            EXECUTABLE_PREFIX = lib;
                            EXECUTABLE_SUFFIX = ".a";
                            GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
                            GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
                            GCC_OPTIMIZATION_LEVEL = 0;
                            GCC_PRECOMPILE_PREFIX_HEADER = YES;
                            GCC_PREFIX_HEADER = "/Users/stebro/daemon/legacy/Client/Mac/MSDEV/HashDefines.h";
                            GCC_PREPROCESSOR_DEFINITIONS = ("'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'", "'PRODVER_STRING=\"99.9.9d1 build 999 (2008-01-01 12:00:00)\"'", "'PRODVER_FULL=\"99.9.999\"'", "'PRODVER_MAJOR=99'", "'PRODVER_MINOR=9'", "'PRODVER_BUILD_NO=999'", _XCODE, );
                            GCC_SYMBOLS_PRIVATE_EXTERN = NO;
                            HEADER_SEARCH_PATHS = (/Volumes/ToolChain/include, /Users/stebro/daemon/legacy/Client/Mac/MSDEV, /Users/stebro/daemon/legacy/Client/Mac/MSDEV/mac/include, /Users/stebro/daemon/legacy/Client/Mac/MSDEV/INCLUDE, );
                            INSTALL_PATH = "";
                            LIBRARY_STYLE = STATIC;
                            OTHER_CFLAGS = " -Werror -Wno-c++11-extensions -Wno-c99-extensions -Wno-c++98-compat -Wno-\#warnings";
                            OTHER_CPLUSPLUSFLAGS = " -Werror -Wno-c++11-extensions -Wno-c99-extensions -Wno-c++98-compat -Wno-\#warnings";
                            OTHER_LDFLAGS = "";
                            OTHER_REZFLAGS = "";
                            PRODUCT_NAME = MacMSDEV;
                            SECTORDER_FLAGS = "";
                            SYMROOT = /Users/stebro/build_xcode/daemon/MacMSDEV;
                            USE_HEADERMAP = NO;
                            WARNING_CFLAGS = ("-Wmost", "-Wno-four-char-constants", "-Wno-unknown-pragmas", );
                     };
                     name = Debug;
              };

   ...

   /* Begin PBXBuildFile section */
   18912E836D484A05B1FC59C5 /* /Users/stebro/daemon/legacy/Client/Mac/MSDEV/AdvAPI32/Registry.cpp */ = {isa = PBXBuildFile; fileRef = A7FC32CB884845CE8F7194D4 /* /Users/stebro/daemon/legacy/Client/Mac/MSDEV/AdvAPI32/Registry.cpp */; settings = { COMPILER_FLAGS = ""; }; };

   ...

   /* Begin PBXFileReference section */
   A7FC32CB884845CE8F7194D4 /* /Users/stebro/daemon/legacy/Client/Mac/MSDEV/AdvAPI32/Registry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.cpp.cpp"; name = "Registry.cpp"; path = "legacy/Client/Mac/MSDEV/AdvAPI32/Registry.cpp"; sourceTree = SOURCE_ROOT; };

   ...

              AD3E059721084BC0933AA316 /* Source Files */ = {
                     isa = PBXGroup;
                     children = (
                            A7FC32CB884845CE8F7194D4 /* /Users/stebro/daemon/legacy/Client/Mac/MSDEV/AdvAPI32/Registry.cpp */,

   ...

   /* Begin PBXSourcesBuildPhase section */
              731899E5CD5D48D18C8C9C21 /* Sources */ = {
                     isa = PBXSourcesBuildPhase;
                     buildActionMask = 2147483647;
                     files = (
                            18912E836D484A05B1FC59C5 /* /Users/stebro/daemon/legacy/Client/Mac/MSDEV/AdvAPI32/Registry.cpp */,