Merge topic '15687-revisit-xcode-system-include'

88f07fb4 Xcode: Properly mark SYSTEM includes as such
This commit is contained in:
Brad King 2017-01-09 16:27:28 -05:00 committed by CMake Topic Stage
commit 4ce6cd2bcf
3 changed files with 30 additions and 5 deletions

View File

@ -1977,6 +1977,22 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList());
}
if (this->XcodeVersion >= 60) {
// Add those per-language flags in addition to HEADER_SEARCH_PATHS to gain
// system include directory awareness. We need to also keep on setting
// HEADER_SEARCH_PATHS to work around a missing compile options flag for
// GNU assembly files (#16449)
for (std::set<std::string>::iterator li = languages.begin();
li != languages.end(); ++li) {
std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags(
includes, gtgt, *li, true, false, configName);
if (!includeFlags.empty()) {
cflags[*li] += " " + includeFlags;
}
}
}
bool same_gflags = true;
std::map<std::string, std::string> gflags;
std::string const* last_gflag = 0;

View File

@ -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)

View File

@ -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
"$<$<CONFIG:${testConfig}>:${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
"$<$<CONFIG:${testConfig}>:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>"
)
endif()
add_library(consumer consumer.cpp)
target_link_libraries(consumer upstream config_specific)