diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-02-17 15:25:29 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-02-28 13:24:03 (GMT) |
commit | fcbd723a5085c11c57ec966f8aea605a55d0bdd5 (patch) | |
tree | c3063c72d82eaf6044342ac1ad8bdd7bcd1e4758 | |
parent | 22a491c3ea790532511e8de09692ccd002447c9d (diff) | |
download | CMake-fcbd723a5085c11c57ec966f8aea605a55d0bdd5.zip CMake-fcbd723a5085c11c57ec966f8aea605a55d0bdd5.tar.gz CMake-fcbd723a5085c11c57ec966f8aea605a55d0bdd5.tar.bz2 |
Enhance support functions
* Avoid duplicate definiitions for IsExecutableWithExports, etc...
* Add helper IsApple()
-rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 4 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 36 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 5 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 17 | ||||
-rw-r--r-- | Source/cmTarget.h | 2 |
8 files changed, 48 insertions, 32 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 1705763..59448a4 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -248,7 +248,7 @@ std::string cmCommonTargetGenerator::GetManifests(const std::string& config) std::string cmCommonTargetGenerator::GetAIXExports(std::string const&) { std::string aixExports; - if (this->GeneratorTarget->Target->IsAIX()) { + if (this->GeneratorTarget->IsAIX()) { if (cmValue exportAll = this->GeneratorTarget->GetProperty("AIX_EXPORT_ALL_SYMBOLS")) { if (cmIsOff(*exportAll)) { diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index ff688a4..78508f3 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1157,7 +1157,7 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry) // Pass the full path to the target file. BT<std::string> lib = BT<std::string>( tgt->GetFullPath(config, artifact, true), item.Backtrace); - if (tgt->Target->IsAIX() && cmHasLiteralSuffix(lib.Value, "-NOTFOUND") && + if (tgt->IsAIX() && cmHasLiteralSuffix(lib.Value, "-NOTFOUND") && artifact == cmStateEnums::ImportLibraryArtifact) { // This is an imported executable on AIX that has ENABLE_EXPORTS // but not IMPORTED_IMPLIB. CMake used to produce and accept such @@ -1185,7 +1185,7 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry) if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s) || (entry.Feature == DEFAULT && cmSystemTools::IsPathToFramework(item.Value) && - this->Makefile->IsOn("APPLE"))) { + this->Target->IsApple())) { // This is a framework. this->AddFrameworkItem(entry); } else if (cmSystemTools::FileIsFullPath(item.Value)) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index be6456b..446e908 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3074,6 +3074,16 @@ void cmGeneratorTarget::ComputeModuleDefinitionInfo( } } +bool cmGeneratorTarget::IsAIX() const +{ + return this->Target->IsAIX(); +} + +bool cmGeneratorTarget::IsApple() const +{ + return this->Target->IsApple(); +} + bool cmGeneratorTarget::IsDLLPlatform() const { return this->Target->IsDLLPlatform(); @@ -3412,7 +3422,7 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory( void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector<std::string>& archVec) const { - if (!this->Makefile->IsOn("APPLE")) { + if (!this->IsApple()) { return; } cmValue archs = nullptr; @@ -3910,7 +3920,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories( AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES", lang, &dagChecker, entries, IncludeRuntimeInterface::Yes); - if (this->Makefile->IsOn("APPLE")) { + if (this->IsApple()) { if (cmLinkImplementationLibraries const* impl = this->GetLinkImplementationLibraries(config, LinkInterfaceFor::Usage)) { @@ -6757,12 +6767,12 @@ void cmGeneratorTarget::ComputeVersionedName( std::string& vName, std::string const& prefix, std::string const& base, std::string const& suffix, std::string const& name, cmValue version) const { - vName = this->Makefile->IsOn("APPLE") ? (prefix + base) : name; + vName = this->IsApple() ? (prefix + base) : name; if (version) { vName += "."; vName += *version; } - vName += this->Makefile->IsOn("APPLE") ? suffix : std::string(); + vName += this->IsApple() ? suffix : std::string(); } std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const @@ -8531,8 +8541,7 @@ bool cmGeneratorTarget::HasContextDependentSources() const bool cmGeneratorTarget::IsExecutableWithExports() const { - return (this->GetType() == cmStateEnums::EXECUTABLE && - this->GetPropertyAsBool("ENABLE_EXPORTS")); + return this->Target->IsExecutableWithExports(); } bool cmGeneratorTarget::HasImportLibrary(std::string const& config) const @@ -8543,7 +8552,7 @@ bool cmGeneratorTarget::HasImportLibrary(std::string const& config) const // Assemblies which have only managed code do not have // import libraries. this->GetManagedType(config) != ManagedType::Managed) || - (this->Target->IsAIX() && this->IsExecutableWithExports()); + (this->IsAIX() && this->IsExecutableWithExports()); } bool cmGeneratorTarget::NeedImportLibraryName(std::string const& config) const @@ -8581,17 +8590,12 @@ bool cmGeneratorTarget::IsLinkable() const bool cmGeneratorTarget::IsFrameworkOnApple() const { - return ((this->GetType() == cmStateEnums::SHARED_LIBRARY || - this->GetType() == cmStateEnums::STATIC_LIBRARY) && - this->Makefile->IsOn("APPLE") && - this->GetPropertyAsBool("FRAMEWORK")); + return this->Target->IsFrameworkOnApple(); } bool cmGeneratorTarget::IsAppBundleOnApple() const { - return (this->GetType() == cmStateEnums::EXECUTABLE && - this->Makefile->IsOn("APPLE") && - this->GetPropertyAsBool("MACOSX_BUNDLE")); + return this->Target->IsAppBundleOnApple(); } bool cmGeneratorTarget::IsXCTestOnApple() const @@ -8601,8 +8605,8 @@ bool cmGeneratorTarget::IsXCTestOnApple() const bool cmGeneratorTarget::IsCFBundleOnApple() const { - return (this->GetType() == cmStateEnums::MODULE_LIBRARY && - this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("BUNDLE")); + return (this->GetType() == cmStateEnums::MODULE_LIBRARY && this->IsApple() && + this->GetPropertyAsBool("BUNDLE")); } cmGeneratorTarget::ManagedType cmGeneratorTarget::CheckManagedType( diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e46c719..f1014d9 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -389,6 +389,11 @@ public: ModuleDefinitionInfo const* GetModuleDefinitionInfo( std::string const& config) const; + /** Return whether or not we are targeting AIX. */ + bool IsAIX() const; + /** Return whether or not we are targeting Apple. */ + bool IsApple() const; + /** Return whether or not the target is for a DLL platform. */ bool IsDLLPlatform() const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 16c5002..e837cc3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -784,7 +784,7 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent, } // Don't handle OSX Bundles. - if (this->Target->Target->GetMakefile()->IsOn("APPLE") && + if (this->Target->IsApple() && this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) { return; } @@ -796,7 +796,7 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent, std::string stripArgs; // macOS 'strip' is picky, executables need '-u -r' and dylibs need '-x'. - if (this->Target->Target->GetMakefile()->IsOn("APPLE")) { + if (this->Target->IsApple()) { if (this->Target->GetType() == cmStateEnums::SHARED_LIBRARY || this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) { stripArgs = "-x "; @@ -822,7 +822,7 @@ void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, Indent indent, // Perform post-installation processing on the file depending // on its type. - if (!this->Target->Target->GetMakefile()->IsOn("APPLE")) { + if (!this->Target->IsApple()) { return; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c2138ee..0271ee4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1644,7 +1644,7 @@ static std::string GetFrameworkFlags(const std::string& lang, cmLocalGenerator* lg = target->GetLocalGenerator(); cmMakefile* mf = lg->GetMakefile(); - if (!mf->IsOn("APPLE")) { + if (!target->IsApple()) { return std::string(); } @@ -1818,7 +1818,7 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065( // OLD behavior is to always add the flags, except on AIX where // we compute symbol exports if ENABLE_EXPORTS is on. add_shlib_flags = - !(tgt.Target->IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS")); + !(tgt.IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS")); break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: @@ -1830,7 +1830,7 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065( // NEW behavior is to only add the flags if ENABLE_EXPORTS is on, // except on AIX where we compute symbol exports. add_shlib_flags = - !tgt.Target->IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS"); + !tgt.IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS"); break; } @@ -1864,7 +1864,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, const std::string& filterArch) { // Only add Apple specific flags on Apple platforms - if (this->Makefile->IsOn("APPLE") && this->EmitUniversalBinaryFlags) { + if (target->IsApple() && this->EmitUniversalBinaryFlags) { std::vector<std::string> archs; target->GetAppleArchs(config, archs); if (!archs.empty() && diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 91d5de6..9ae2576 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -611,7 +611,6 @@ TargetProperty const StaticTargetProperties[] = { #undef COMMON_LANGUAGE_PROPERTIES #undef IC #undef R - } class cmTargetInternals @@ -628,6 +627,7 @@ public: bool HaveInstallRule; bool IsDLLPlatform; bool IsAIX; + bool IsApple; bool IsAndroid; bool BuildInterfaceIncludesAppended; bool PerConfig; @@ -914,6 +914,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->impl->HaveInstallRule = false; this->impl->IsDLLPlatform = false; this->impl->IsAIX = false; + this->impl->IsApple = false; this->impl->IsAndroid = false; this->impl->TargetVisibility = vis; this->impl->BuildInterfaceIncludesAppended = false; @@ -931,6 +932,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->impl->IsAIX = (systemName == "AIX" || systemName == "OS400"); } + // Check whether we are targeting Apple. + this->impl->IsApple = this->impl->Makefile->IsOn("APPLE"); + // Check whether we are targeting an Android platform. this->impl->IsAndroid = (this->impl->Makefile->GetSafeDefinition( "CMAKE_SYSTEM_NAME") == "Android"); @@ -1205,14 +1209,12 @@ bool cmTarget::IsFrameworkOnApple() const { return ((this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::STATIC_LIBRARY) && - this->impl->Makefile->IsOn("APPLE") && - this->GetPropertyAsBool("FRAMEWORK")); + this->IsApple() && this->GetPropertyAsBool("FRAMEWORK")); } bool cmTarget::IsAppBundleOnApple() const { - return (this->GetType() == cmStateEnums::EXECUTABLE && - this->impl->Makefile->IsOn("APPLE") && + return (this->GetType() == cmStateEnums::EXECUTABLE && this->IsApple() && this->GetPropertyAsBool("MACOSX_BUNDLE")); } @@ -1774,7 +1776,6 @@ std::string ConvertToString<cmValue>(cmValue value) { return std::string(*value); } - } template <typename ValueType> @@ -2553,6 +2554,10 @@ bool cmTarget::IsAIX() const { return this->impl->IsAIX; } +bool cmTarget::IsApple() const +{ + return this->impl->IsApple; +} bool cmTarget::IsNormal() const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 95539fa..95523f4 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -205,6 +205,8 @@ public: //! Return whether or not we are targeting AIX. bool IsAIX() const; + //! Return whether or not we are targeting Apple. + bool IsApple() const; bool IsNormal() const; bool IsSynthetic() const; |