mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-01 11:22:21 -06:00
Apple: Merge per-arch sysroot parameters if all are the same
Since commit a9b41195d2 (Handle multi-arch sysroots on Apple platforms,
2019-07-26, v3.17.0-rc1~287^2), CMake supports "fat" builds with
different sysroots. Those are passed to the compiler with the
`-Xarch_<xyz>` parameter.
Unfortunately this breaks the Compiler Cache (ccache) because
it does not support those compiler flags:
https://github.com/ccache/ccache/blob/v3.7.9/src/ccache.c#L2700-L2705
Restore the caching ability for certain "fat" build configurations (e.g.
`arm64` and `armv7`) where the sysroot is the same for all selected
architectures and thus a plain `-isysroot` parameter could be used.
This commit is contained in:
@@ -1789,6 +1789,26 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065(
|
||||
return linkFlags;
|
||||
}
|
||||
|
||||
bool cmLocalGenerator::AllAppleArchSysrootsAreTheSame(
|
||||
const std::vector<std::string>& archs, const char* sysroot)
|
||||
{
|
||||
if (!sysroot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (std::string const& arch : archs) {
|
||||
std::string const& archSysroot = this->AppleArchSysroots[arch];
|
||||
if (cmIsOff(archSysroot)) {
|
||||
continue;
|
||||
}
|
||||
if (archSysroot != sysroot) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
|
||||
cmGeneratorTarget const* target,
|
||||
const std::string& lang,
|
||||
@@ -1814,7 +1834,8 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
|
||||
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
|
||||
const char* sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar);
|
||||
if (sysrootFlag && *sysrootFlag) {
|
||||
if (!this->AppleArchSysroots.empty()) {
|
||||
if (!this->AppleArchSysroots.empty() &&
|
||||
!this->AllAppleArchSysrootsAreTheSame(archs, sysroot)) {
|
||||
for (std::string const& arch : archs) {
|
||||
std::string const& archSysroot = this->AppleArchSysroots[arch];
|
||||
if (cmIsOff(archSysroot)) {
|
||||
|
||||
@@ -528,6 +528,8 @@ private:
|
||||
int targetType);
|
||||
|
||||
void ComputeObjectMaxPath();
|
||||
bool AllAppleArchSysrootsAreTheSame(const std::vector<std::string>& archs,
|
||||
const char* sysroot);
|
||||
};
|
||||
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
|
||||
Reference in New Issue
Block a user