MCPcopy Create free account
hub / github.com/Kitware/CMake / AddArchitectureFlags

Method AddArchitectureFlags

Source/cmLocalGenerator.cxx:1957–2058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1955}
1956
1957void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
1958 cmGeneratorTarget const* target,
1959 std::string const& lang,
1960 std::string const& config,
1961 std::string const& filterArch)
1962{
1963 // Only add Apple specific flags on Apple platforms
1964 if (target->IsApple() && this->EmitUniversalBinaryFlags) {
1965 std::vector<std::string> archs = target->GetAppleArchs(config, lang);
1966 if (!archs.empty() &&
1967 (lang == "C" || lang == "CXX" || lang == "OBJC" || lang == "OBJCXX" ||
1968 lang == "ASM")) {
1969 for (std::string const& arch : archs) {
1970 if (filterArch.empty() || filterArch == arch) {
1971 flags += " -arch ";
1972 flags += arch;
1973 }
1974 }
1975 }
1976
1977 cmValue sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
1978 if (sysroot.IsEmpty() &&
1979 this->Makefile->IsOn(
1980 cmStrCat("CMAKE_", lang, "_COMPILER_APPLE_SYSROOT_REQUIRED"))) {
1981 sysroot = this->Makefile->GetDefinition("_CMAKE_OSX_SYSROOT_PATH");
1982 }
1983 if (sysroot && *sysroot == "/") {
1984 sysroot = nullptr;
1985 }
1986 std::string sysrootFlagVar = "CMAKE_" + lang + "_SYSROOT_FLAG";
1987 cmValue sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar);
1988 if (cmNonempty(sysrootFlag)) {
1989 if (!this->AppleArchSysroots.empty() &&
1990 !this->AllAppleArchSysrootsAreTheSame(archs, sysroot)) {
1991 for (std::string const& arch : archs) {
1992 std::string const& archSysroot = this->AppleArchSysroots[arch];
1993 if (cmIsOff(archSysroot)) {
1994 continue;
1995 }
1996 if (filterArch.empty() || filterArch == arch) {
1997 flags += " -Xarch_" + arch + " ";
1998 // Combine sysroot flag and path to work with -Xarch
1999 std::string arch_sysroot = *sysrootFlag + archSysroot;
2000 flags += this->ConvertToOutputFormat(arch_sysroot, SHELL);
2001 }
2002 }
2003 } else if (cmNonempty(sysroot)) {
2004 flags += " ";
2005 flags += *sysrootFlag;
2006 flags += " ";
2007 flags += this->ConvertToOutputFormat(*sysroot, SHELL);
2008 }
2009 }
2010
2011 cmValue deploymentTarget =
2012 this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
2013 if (cmNonempty(deploymentTarget)) {
2014 std::string deploymentTargetFlagVar =

Callers 5

GetTargetCompileFlagsMethod · 0.95
WriteExecutableRuleMethod · 0.80
WriteLibraryRulesMethod · 0.80
WriteLinkStatementMethod · 0.80

Calls 15

cmNonemptyFunction · 0.85
cmIsOffFunction · 0.85
cmHasLiteralPrefixFunction · 0.85
GetAppleArchsMethod · 0.80
cmStrCatFunction · 0.70
IsAppleMethod · 0.45
emptyMethod · 0.45
GetDefinitionMethod · 0.45
IsEmptyMethod · 0.45
IsOnMethod · 0.45
ConvertToOutputFormatMethod · 0.45

Tested by

no test coverage detected