1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 22:37:30 +08:00

De-duplicate checks for whether a platform uses Windows DLLs

This commit is contained in:
Brad King
2019-07-12 13:36:15 -04:00
parent 22d3eb5d5e
commit 79f5ef19fe
5 changed files with 15 additions and 15 deletions

View File

@@ -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<std::string>& result,

View File

@@ -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;

View File

@@ -389,10 +389,6 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> 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<std::string> 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<std::string> 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(

View File

@@ -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()));

View File

@@ -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;