summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Jasny <gjasny@googlemail.com>2019-02-05 14:23:31 +0100
committerBrad King <brad.king@kitware.com>2019-02-07 06:43:51 -0500
commit8af334f5baa1a628895571491f67a4f7d9483d9b (patch)
tree23ed607ee777b3b3bfbbee6bde97794d3c6b0730
parent6f23321d405930241fa431cfda7650f2993f0c19 (diff)
downloadcmake-8af334f5baa1a628895571491f67a4f7d9483d9b.tar.gz
Xcode: Derive stdlib from CXX flags
Closes: #18396
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake9
-rw-r--r--Modules/CompilerId/Xcode-3.pbxproj.in1
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx16
3 files changed, 26 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 2f84c8eac5..83ce39249c 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -360,6 +360,15 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
else()
set(id_sdkroot "")
endif()
+ set(id_clang_cxx_library "")
+ set(stdlib_regex "(^| )(-stdlib=)([^ ]+)( |$)")
+ string(REGEX MATCHALL "${stdlib_regex}" all_stdlib_matches "${CMAKE_CXX_FLAGS}")
+ if(all_stdlib_matches)
+ list(GET all_stdlib_matches "-1" last_stdlib_match)
+ if(last_stdlib_match MATCHES "${stdlib_regex}")
+ set(id_clang_cxx_library "CLANG_CXX_LIBRARY = \"${CMAKE_MATCH_3}\";")
+ endif()
+ endif()
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in
${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY)
unset(_ENV_MACOSX_DEPLOYMENT_TARGET)
diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in
index 813c0740b9..672044e135 100644
--- a/Modules/CompilerId/Xcode-3.pbxproj.in
+++ b/Modules/CompilerId/Xcode-3.pbxproj.in
@@ -86,6 +86,7 @@
SYMROOT = .;
@id_toolset@
@id_lang_version@
+ @id_clang_cxx_library@
@id_deployment_target@
@id_sdkroot@
};
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 16f8a0ee47..51c001e753 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2254,6 +2254,22 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
debugStr = "NO";
}
+ // extract C++ stdlib
+ for (auto const& language : languages) {
+ if (language != "CXX") {
+ continue;
+ }
+ std::string& flags = cflags[language];
+
+ auto stdlib =
+ this->ExtractFlagRegex("(^| )(-stdlib=[^ ]+)( |$)", 2, flags);
+ if (stdlib.size() > 8) {
+ const auto cxxLibrary = stdlib.substr(8);
+ buildSettings->AddAttribute("CLANG_CXX_LIBRARY",
+ this->CreateString(cxxLibrary));
+ }
+ }
+
buildSettings->AddAttribute("COMBINE_HIDPI_IMAGES",
this->CreateString("YES"));
buildSettings->AddAttribute("GCC_GENERATE_DEBUGGING_SYMBOLS",