diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-05-17 17:50:32 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-07-26 21:00:01 (GMT) |
commit | 7050ac56a11768c90f55654aa3f63d02bb549243 (patch) | |
tree | a436ee5be767bfd776dc93d747abd122a94f3a34 /Source/cmLocalGenerator.cxx | |
parent | 93ed53790cb1e2d5f25f26156ee5c6590b0d3150 (diff) | |
download | CMake-7050ac56a11768c90f55654aa3f63d02bb549243.zip CMake-7050ac56a11768c90f55654aa3f63d02bb549243.tar.gz CMake-7050ac56a11768c90f55654aa3f63d02bb549243.tar.bz2 |
macOS: Add support for linking against .xcframework folders
Issue: #21752
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index cf1eb96..acefedc 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1659,6 +1659,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetTargetCompileFlags( this->AppendFlags(compileFlags, mf->GetDefineFlags()); this->AppendFlags(compileFlags, this->GetFrameworkFlags(lang, config, target)); + this->AppendFlags(compileFlags, + this->GetXcFrameworkFlags(lang, config, target)); if (!compileFlags.empty()) { flags.emplace_back(std::move(compileFlags)); @@ -1724,6 +1726,43 @@ std::string cmLocalGenerator::GetFrameworkFlags(std::string const& lang, return flags; } +std::string cmLocalGenerator::GetXcFrameworkFlags(std::string const& lang, + std::string const& config, + cmGeneratorTarget* target) +{ + cmLocalGenerator* lg = target->GetLocalGenerator(); + cmMakefile* mf = lg->GetMakefile(); + + if (!target->IsApple()) { + return std::string(); + } + + cmValue includeSearchFlag = + mf->GetDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_", lang)); + cmValue sysIncludeSearchFlag = + mf->GetDefinition(cmStrCat("CMAKE_INCLUDE_SYSTEM_FLAG_", lang)); + + if (!includeSearchFlag && !sysIncludeSearchFlag) { + return std::string{}; + } + + std::string flags; + if (cmComputeLinkInformation* cli = target->GetLinkInformation(config)) { + std::vector<std::string> const& paths = cli->GetXcFrameworkHeaderPaths(); + for (std::string const& path : paths) { + if (sysIncludeSearchFlag && + target->IsSystemIncludeDirectory(path, config, lang)) { + flags += *sysIncludeSearchFlag; + } else { + flags += *includeSearchFlag; + } + flags += lg->ConvertToOutputFormat(path, cmOutputConverter::SHELL); + flags += " "; + } + } + return flags; +} + void cmLocalGenerator::GetTargetDefines(cmGeneratorTarget const* target, std::string const& config, std::string const& lang, |