diff options
author | Gregor Jasny <gjasny@googlemail.com> | 2019-02-05 13:23:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-02-07 11:43:51 (GMT) |
commit | 8af334f5baa1a628895571491f67a4f7d9483d9b (patch) | |
tree | 23ed607ee777b3b3bfbbee6bde97794d3c6b0730 | |
parent | 6f23321d405930241fa431cfda7650f2993f0c19 (diff) | |
download | CMake-8af334f5baa1a628895571491f67a4f7d9483d9b.zip CMake-8af334f5baa1a628895571491f67a4f7d9483d9b.tar.gz CMake-8af334f5baa1a628895571491f67a4f7d9483d9b.tar.bz2 |
Xcode: Derive stdlib from CXX flags
Closes: #18396
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 9 | ||||
-rw-r--r-- | Modules/CompilerId/Xcode-3.pbxproj.in | 1 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 16 |
3 files changed, 26 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 2f84c8e..83ce392 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 813c074..672044e 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 16f8a0e..51c001e 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", |