From 79f5ef19fe418efe2d9bfc55fcd16dfd75f18d49 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 12 Jul 2019 13:36:15 -0400 Subject: De-duplicate checks for whether a platform uses Windows DLLs --- Source/cmGeneratorTarget.cxx | 5 +---- Source/cmGeneratorTarget.h | 1 - Source/cmInstallCommand.cxx | 8 ++------ Source/cmTarget.cxx | 13 +++++++++---- Source/cmTarget.h | 3 +++ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 54f6e80..c807f6d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -259,9 +259,6 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetSourceBacktraces(), this->SourceEntries, true); - this->DLLPlatform = - !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); - this->PolicyMap = t->GetPolicyMap(); } @@ -2357,7 +2354,7 @@ void cmGeneratorTarget::ComputeModuleDefinitionInfo( bool cmGeneratorTarget::IsDLLPlatform() const { - return this->DLLPlatform; + return this->Target->IsDLLPlatform(); } void cmGeneratorTarget::GetAutoUicOptions(std::vector& result, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 852f8fd..e86535d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -913,7 +913,6 @@ private: mutable bool DebugSourcesDone; mutable bool LinkImplementationLanguageIsContextDependent; mutable bool UtilityItemsDone; - bool DLLPlatform; bool ComputePDBOutputDir(const std::string& kind, const std::string& config, std::string& out) const; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index dba4bbb..750ed8c 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -389,10 +389,6 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) return true; } - // Check whether this is a DLL platform. - bool dll_platform = - !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); - for (std::string const& tgt : targetList) { if (this->Makefile->IsAlias(tgt)) { @@ -472,7 +468,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Shared libraries are handled differently on DLL and non-DLL // platforms. All windows platforms are DLL platforms including // cygwin. Currently no other platform is a DLL platform. - if (dll_platform) { + if (target.IsDLLPlatform()) { // When in namelink only mode skip all libraries on Windows. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { continue; @@ -641,7 +637,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // On DLL platforms an executable may also have an import // library. Install it to the archive destination if it // exists. - if (dll_platform && !archiveArgs.GetDestination().empty() && + if (target.IsDLLPlatform() && !archiveArgs.GetDestination().empty() && target.IsExecutableWithExports()) { // The import library uses the ARCHIVE properties. archiveGenerator = CreateInstallTargetGenerator( diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b10b30f..2237d9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -168,7 +168,7 @@ public: cmPropertyMap Properties; bool IsGeneratorProvided; bool HaveInstallRule; - bool DLLPlatform; + bool IsDLLPlatform; bool IsAndroid; bool IsImportedTarget; bool ImportedGloballyVisible; @@ -216,7 +216,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->Name = name; impl->IsGeneratorProvided = false; impl->HaveInstallRule = false; - impl->DLLPlatform = false; + impl->IsDLLPlatform = false; impl->IsAndroid = false; impl->IsImportedTarget = (vis == VisibilityImported || vis == VisibilityImportedGlobally); @@ -224,7 +224,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->BuildInterfaceIncludesAppended = false; // Check whether this is a DLL platform. - impl->DLLPlatform = + impl->IsDLLPlatform = !impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); // Check whether we are targeting an Android platform. @@ -1657,6 +1657,11 @@ cmPropertyMap const& cmTarget::GetProperties() const return impl->Properties; } +bool cmTarget::IsDLLPlatform() const +{ + return impl->IsDLLPlatform; +} + bool cmTarget::IsImported() const { return impl->IsImportedTarget; @@ -1872,7 +1877,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, // If we needed to find one of the mapped configurations but did not // On a DLL platform there may be only IMPORTED_IMPLIB for a shared // library or an executable with exports. - bool allowImp = (impl->DLLPlatform && + bool allowImp = (this->IsDLLPlatform() && (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->IsExecutableWithExports())); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f47cc14..d9e87b8 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -177,6 +177,9 @@ public: //! Get all properties cmPropertyMap const& GetProperties() const; + //! Return whether or not the target is for a DLL platform. + bool IsDLLPlatform() const; + bool IsImported() const; bool IsImportedGloballyVisible() const; -- cgit v0.12