Merge topic '15687-xcode-support-system-include'
93ac2a78
Xcode: Obey SYSTEM keyword for includes (#15687)
This commit is contained in:
commit
50ada755e3
|
@ -13,6 +13,7 @@
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
set(CMAKE_Swift_OUTPUT_EXTENSION .o)
|
set(CMAKE_Swift_OUTPUT_EXTENSION .o)
|
||||||
|
set(CMAKE_INCLUDE_FLAG_Swift "-I")
|
||||||
|
|
||||||
# Load compiler-specific information.
|
# Load compiler-specific information.
|
||||||
if(CMAKE_Swift_COMPILER_ID)
|
if(CMAKE_Swift_COMPILER_ID)
|
||||||
|
|
|
@ -1907,23 +1907,40 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
|
||||||
|
|
||||||
BuildObjectListOrString dirs(this, this->XcodeVersion >= 30);
|
BuildObjectListOrString dirs(this, this->XcodeVersion >= 30);
|
||||||
BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30);
|
BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30);
|
||||||
std::vector<std::string> includes;
|
|
||||||
this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C",
|
|
||||||
configName);
|
|
||||||
std::set<std::string> emitted;
|
std::set<std::string> emitted;
|
||||||
emitted.insert("/System/Library/Frameworks");
|
emitted.insert("/System/Library/Frameworks");
|
||||||
for (std::vector<std::string>::iterator i = includes.begin();
|
|
||||||
i != includes.end(); ++i) {
|
if (this->XcodeVersion < 60) {
|
||||||
if (this->NameResolvesToFramework(i->c_str())) {
|
std::vector<std::string> includes;
|
||||||
std::string frameworkDir = *i;
|
this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C",
|
||||||
frameworkDir += "/../";
|
configName);
|
||||||
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
|
for (std::vector<std::string>::iterator i = includes.begin();
|
||||||
if (emitted.insert(frameworkDir).second) {
|
i != includes.end(); ++i) {
|
||||||
fdirs.Add(this->XCodeEscapePath(frameworkDir));
|
if (this->NameResolvesToFramework(i->c_str())) {
|
||||||
|
std::string frameworkDir = *i;
|
||||||
|
frameworkDir += "/../";
|
||||||
|
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
|
||||||
|
if (emitted.insert(frameworkDir).second) {
|
||||||
|
fdirs.Add(this->XCodeEscapePath(frameworkDir));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::string incpath = this->XCodeEscapePath(*i);
|
||||||
|
dirs.Add(incpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (std::set<std::string>::iterator li = languages.begin();
|
||||||
|
li != languages.end(); ++li) {
|
||||||
|
std::vector<std::string> includes;
|
||||||
|
this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, *li,
|
||||||
|
configName);
|
||||||
|
std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags(
|
||||||
|
includes, gtgt, *li, true, false, configName);
|
||||||
|
|
||||||
|
std::string& flags = cflags[*li];
|
||||||
|
if (!includeFlags.empty()) {
|
||||||
|
flags += " " + includeFlags;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
std::string incpath = this->XCodeEscapePath(*i);
|
|
||||||
dirs.Add(incpath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add framework search paths needed for linking.
|
// Add framework search paths needed for linking.
|
||||||
|
@ -2008,6 +2025,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
|
||||||
this->CreateString(flags));
|
this->CreateString(flags));
|
||||||
} else if (*li == "C") {
|
} else if (*li == "C") {
|
||||||
buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags));
|
buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags));
|
||||||
|
} else if (*li == "Swift") {
|
||||||
|
buildSettings->AddAttribute("OTHER_SWIFT_FLAGS",
|
||||||
|
this->CreateString(flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@ project(IncludeDirectories)
|
||||||
|
|
||||||
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
|
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)
|
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)
|
include(CheckCXXCompilerFlag)
|
||||||
check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
|
check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
|
||||||
if(run_sys_includes_test)
|
if(run_sys_includes_test)
|
||||||
|
|
|
@ -15,10 +15,17 @@ target_include_directories(upstream SYSTEM PUBLIC
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(config_specific INTERFACE)
|
add_library(config_specific INTERFACE)
|
||||||
set(testConfig ${CMAKE_BUILD_TYPE})
|
if(CMAKE_GENERATOR STREQUAL "Xcode")
|
||||||
target_include_directories(config_specific SYSTEM INTERFACE
|
# CMAKE_BUILD_TYPE does not work here for multi-config generators
|
||||||
"$<$<CONFIG:${testConfig}>:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>"
|
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)
|
add_library(consumer consumer.cpp)
|
||||||
target_link_libraries(consumer upstream config_specific)
|
target_link_libraries(consumer upstream config_specific)
|
||||||
|
|
Loading…
Reference in New Issue