From 93ac2a78d5e0dbb6607105cc8d2a3f19ebdd8583 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Mon, 31 Aug 2015 22:33:37 +0200 Subject: Xcode: Obey SYSTEM keyword for includes (#15687) CMake used to put all header search paths into HEADER_SEARCH_PATHS attribute. Unfortunately this attribute does not support to declare a search path as a system include. As a hack one could add a -isystem /path to the cflags but then include ordering is not deterministic. A better approach was chosen with this patch by not filling HEADER_SEARCH_PATHS at all and to populate the C, C++, and Fortran flags directly. The include paths used by Xcode should be now identical to the ones used by Unix Makefiles and Ninja generator. --- Tests/IncludeDirectories/CMakeLists.txt | 4 +++- .../SystemIncludeDirectories/CMakeLists.txt | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'Tests') diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 49205828f1..db18462a86 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -3,7 +3,9 @@ project(IncludeDirectories) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) - AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) + AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" + OR CMAKE_GENERATOR STREQUAL "Ninja" + OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) if(run_sys_includes_test) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index dcee85eb48..5078f30999 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -15,10 +15,17 @@ target_include_directories(upstream SYSTEM PUBLIC ) add_library(config_specific INTERFACE) -set(testConfig ${CMAKE_BUILD_TYPE}) -target_include_directories(config_specific SYSTEM INTERFACE - "$<$:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>" -) +if(CMAKE_GENERATOR STREQUAL "Xcode") + # CMAKE_BUILD_TYPE does not work here for multi-config generators + target_include_directories(config_specific SYSTEM INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/config_specific" + ) +else() + set(testConfig ${CMAKE_BUILD_TYPE}) + target_include_directories(config_specific SYSTEM INTERFACE + "$<$:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>" + ) +endif() add_library(consumer consumer.cpp) target_link_libraries(consumer upstream config_specific) -- cgit v1.2.1