diff options
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 20 | ||||
-rw-r--r-- | Source/cmExportBuildFileGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 8 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 226 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 42 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalVisualStudioGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 24 | ||||
-rw-r--r-- | Source/cmOSXBundleGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmServerProtocol.cxx | 6 | ||||
-rw-r--r-- | Source/cmStateTypes.h | 6 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 142 | ||||
-rw-r--r-- | Source/cmTarget.h | 8 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 8 |
20 files changed, 329 insertions, 210 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 80e7e7d..b273443 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -500,7 +500,10 @@ bool cmComputeLinkInformation::Compute() cmGeneratorTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); - std::string lib = tgt->GetFullPath(this->Config, implib, true); + cmStateEnums::ArtifactType artifact = implib + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + std::string lib = tgt->GetFullPath(this->Config, artifact, true); this->OldLinkDirItems.push_back(lib); } } @@ -596,8 +599,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // platform. Add it now. std::string linkItem; linkItem = this->LoaderFlag; + cmStateEnums::ArtifactType artifact = this->UseImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; - std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true); + std::string exe = tgt->GetFullPath(config, artifact, true); linkItem += exe; this->Items.push_back(Item(linkItem, true, tgt)); this->Depends.push_back(exe); @@ -617,9 +623,12 @@ void cmComputeLinkInformation::AddItem(std::string const& item, bool implib = (this->UseImportLibrary && (impexe || tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); + cmStateEnums::ArtifactType artifact = implib + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; // Pass the full path to the target file. - std::string lib = tgt->GetFullPath(config, implib, true); + std::string lib = tgt->GetFullPath(config, artifact, true); if (!this->LinkDependsNoShared || tgt->GetType() != cmStateEnums::SHARED_LIBRARY) { this->Depends.push_back(lib); @@ -689,7 +698,10 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, // linked will be able to find it. std::string lib; if (tgt) { - lib = tgt->GetFullPath(this->Config, this->UseImportLibrary); + cmStateEnums::ArtifactType artifact = this->UseImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + lib = tgt->GetFullPath(this->Config, artifact); this->AddLibraryRuntimeInfo(lib, tgt); } else { lib = item; diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 978a7a1..a1c424a 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -200,9 +200,11 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( prop += suffix; std::string value; if (target->IsAppBundleOnApple()) { - value = target->GetFullPath(config, false); + value = + target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); } else { - value = target->GetFullPath(config, false, true); + value = target->GetFullPath(config, + cmStateEnums::RuntimeBinaryArtifact, true); } properties[prop] = value; } @@ -212,7 +214,8 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { std::string prop = "IMPORTED_IMPLIB"; prop += suffix; - std::string value = target->GetFullPath(config, true); + std::string value = + target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact); target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 77a4962..e065a74 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1607,7 +1607,10 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> "executables with ENABLE_EXPORTS."); return std::string(); } - return target->GetFullPath(context->Config, target->HasImportLibrary()); + cmStateEnums::ArtifactType artifact = target->HasImportLibrary() + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + return target->GetFullPath(context->Config, artifact); } }; @@ -1668,7 +1671,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactNameTag> cmGeneratorExpressionContext* context, const GeneratorExpressionContent* /*unused*/) { - return target->GetFullPath(context->Config, false, true); + return target->GetFullPath(context->Config, + cmStateEnums::RuntimeBinaryArtifact, true); } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2799505..1d6e7fe 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -216,52 +216,60 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const return this->Target->GetProperty(prop); } -const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const +const char* cmGeneratorTarget::GetOutputTargetType( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::SHARED_LIBRARY: if (this->IsDLLPlatform()) { - if (implib) { - // A DLL import library is treated as an archive target. - return "ARCHIVE"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // A DLL shared library is treated as a runtime target. + return "RUNTIME"; + case cmStateEnums::ImportLibraryArtifact: + // A DLL import library is treated as an archive target. + return "ARCHIVE"; } - // A DLL shared library is treated as a runtime target. - return "RUNTIME"; } else { // For non-DLL platforms shared libraries are treated as // library targets. return "LIBRARY"; } + break; case cmStateEnums::STATIC_LIBRARY: // Static libraries are always treated as archive targets. return "ARCHIVE"; case cmStateEnums::MODULE_LIBRARY: - if (implib) { - // Module libraries are always treated as library targets. - return "ARCHIVE"; - } else { - // Module import libraries are treated as archive targets. - return "LIBRARY"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Module import libraries are treated as archive targets. + return "LIBRARY"; + case cmStateEnums::ImportLibraryArtifact: + // Module libraries are always treated as library targets. + return "ARCHIVE"; } + break; case cmStateEnums::EXECUTABLE: - if (implib) { - // Executable import libraries are treated as archive targets. - return "ARCHIVE"; - } else { - // Executables are always treated as runtime targets. - return "RUNTIME"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Executables are always treated as runtime targets. + return "RUNTIME"; + case cmStateEnums::ImportLibraryArtifact: + // Executable import libraries are treated as archive targets. + return "ARCHIVE"; } + break; default: break; } return ""; } -std::string cmGeneratorTarget::GetOutputName(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetOutputName( + const std::string& config, cmStateEnums::ArtifactType artifact) const { // Lookup/compute/cache the output name for this configuration. - OutputNameKey key(config, implib); + OutputNameKey key(config, artifact); cmGeneratorTarget::OutputNameMapType::iterator i = this->OutputNameMap.find(key); if (i == this->OutputNameMap.end()) { @@ -271,7 +279,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, // Compute output name. std::vector<std::string> props; - std::string type = this->GetOutputTargetType(implib); + std::string type = this->GetOutputTargetType(artifact); std::string configUpper = cmSystemTools::UpperCase(config); if (!type.empty() && !configUpper.empty()) { // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG> @@ -641,9 +649,10 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const { static std::string location; if (this->IsImported()) { - location = this->Target->ImportedGetFullPath(config, false); + location = this->Target->ImportedGetFullPath( + config, cmStateEnums::RuntimeBinaryArtifact); } else { - location = this->GetFullPath(config, false); + location = this->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); } return location.c_str(); } @@ -680,7 +689,8 @@ const char* cmGeneratorTarget::GetLocationForBuild() const { static std::string location; if (this->IsImported()) { - location = this->Target->ImportedGetFullPath("", false); + location = this->Target->ImportedGetFullPath( + "", cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } @@ -700,7 +710,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->GetFullName("", false); + location += this->GetFullName("", cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } @@ -1145,7 +1155,8 @@ std::string cmGeneratorTarget::GetCompilePDBName( std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -1506,7 +1517,8 @@ static bool shouldAddContentLevel( std::string cmGeneratorTarget::GetAppBundleDirectory( const std::string& config, BundleDirectoryLevel level) const { - std::string fpath = this->GetFullName(config, false); + std::string fpath = + this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1532,7 +1544,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory( const std::string& config, BundleDirectoryLevel level) const { std::string fpath; - fpath += this->GetOutputName(config, false); + fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1556,7 +1568,7 @@ std::string cmGeneratorTarget::GetFrameworkDirectory( const std::string& config, BundleDirectoryLevel level) const { std::string fpath; - fpath += this->GetOutputName(config, false); + fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1570,13 +1582,13 @@ std::string cmGeneratorTarget::GetFrameworkDirectory( return fpath; } -std::string cmGeneratorTarget::GetFullName(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullName( + const std::string& config, cmStateEnums::ArtifactType artifact) const { if (this->IsImported()) { - return this->GetFullNameImported(config, implib); + return this->GetFullNameImported(config, artifact); } - return this->GetFullNameInternal(config, implib); + return this->GetFullNameInternal(config, artifact); } std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -1869,13 +1881,11 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } } -void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, - std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const +void cmGeneratorTarget::GetFullNameComponents( + std::string& prefix, std::string& base, std::string& suffix, + const std::string& config, cmStateEnums::ArtifactType artifact) const { - this->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, artifact, prefix, base, suffix); } std::string cmGeneratorTarget::BuildBundleDirectory( @@ -1896,10 +1906,10 @@ std::string cmGeneratorTarget::BuildBundleDirectory( } std::string cmGeneratorTarget::GetMacContentDirectory( - const std::string& config, bool implib) const + const std::string& config, cmStateEnums::ArtifactType artifact) const { // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, artifact); fpath += "/"; BundleDirectoryLevel level = ContentLevel; if (this->IsFrameworkOnApple()) { @@ -2860,7 +2870,8 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const } // Get the directory. - std::string dir = this->GetDirectory(config, false); + std::string dir = + this->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact); // Add each name. std::string f; @@ -2889,7 +2900,7 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const gg->AddToManifest(f); } if (!impName.empty()) { - f = this->GetDirectory(config, true); + f = this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); f += "/"; f += impName; gg->AddToManifest(f); @@ -2907,19 +2918,20 @@ std::string cmGeneratorTarget::GetImportedLibName( } std::string cmGeneratorTarget::GetFullPath(const std::string& config, - bool implib, bool realname) const + cmStateEnums::ArtifactType artifact, + bool realname) const { if (this->IsImported()) { - return this->Target->ImportedGetFullPath(config, implib); + return this->Target->ImportedGetFullPath(config, artifact); } - return this->NormalGetFullPath(config, implib, realname); + return this->NormalGetFullPath(config, artifact, realname); } -std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, - bool implib, - bool realname) const +std::string cmGeneratorTarget::NormalGetFullPath( + const std::string& config, cmStateEnums::ArtifactType artifact, + bool realname) const { - std::string fpath = this->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, artifact); fpath += "/"; if (this->IsAppBundleOnApple()) { fpath = this->BuildBundleDirectory(fpath, config, FullLevel); @@ -2927,12 +2939,18 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } // Add the full name of the target. - if (implib) { - fpath += this->GetFullName(config, true); - } else if (realname) { - fpath += this->NormalGetRealName(config); - } else { - fpath += this->GetFullName(config, false); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + if (realname) { + fpath += this->NormalGetRealName(config); + } else { + fpath += + this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact); + } + break; + case cmStateEnums::ImportLibraryArtifact: + fpath += this->GetFullName(config, cmStateEnums::ImportLibraryArtifact); + break; } return fpath; } @@ -3009,7 +3027,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // The library name. name = prefix + base + suffix; @@ -3034,7 +3053,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, // The import library name. if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::MODULE_LIBRARY) { - impName = this->GetFullNameInternal(config, true); + impName = + this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); } else { impName = ""; } @@ -3075,7 +3095,8 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // The executable name. name = prefix + base + suffix; @@ -3095,19 +3116,20 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->GetFullNameInternal(config, true); + impName = + this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); // The program database file name. pdbName = this->GetPDBName(config); } -std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullNameInternal( + const std::string& config, cmStateEnums::ArtifactType artifact) const { std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, artifact, prefix, base, suffix); return prefix + base + suffix; } @@ -3116,22 +3138,21 @@ const char* cmGeneratorTarget::ImportedGetLocation( { static std::string location; assert(this->IsImported()); - location = this->Target->ImportedGetFullPath(config, false); + location = this->Target->ImportedGetFullPath( + config, cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } -std::string cmGeneratorTarget::GetFullNameImported(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullNameImported( + const std::string& config, cmStateEnums::ArtifactType artifact) const { return cmSystemTools::GetFilenameName( - this->Target->ImportedGetFullPath(config, implib)); + this->Target->ImportedGetFullPath(config, artifact)); } -void cmGeneratorTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const +void cmGeneratorTarget::GetFullNameInternal( + const std::string& config, cmStateEnums::ArtifactType artifact, + std::string& outPrefix, std::string& outBase, std::string& outSuffix) const { // Use just the target name for non-main target types. if (this->GetType() != cmStateEnums::STATIC_LIBRARY && @@ -3144,9 +3165,12 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, return; } + const bool isImportedLibraryArtifact = + (artifact == cmStateEnums::ImportLibraryArtifact); + // Return an empty name for the import library if this platform // does not support import libraries. - if (implib && + if (isImportedLibraryArtifact && !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { outPrefix = ""; outBase = ""; @@ -3159,14 +3183,16 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if (this->GetType() != cmStateEnums::SHARED_LIBRARY && this->GetType() != cmStateEnums::MODULE_LIBRARY && this->GetType() != cmStateEnums::EXECUTABLE) { - implib = false; + artifact = cmStateEnums::RuntimeBinaryArtifact; } // Compute the full name for main target types. - const char* targetPrefix = (implib ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); + const char* targetPrefix = + (isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = + (isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); const char* configPostfix = CM_NULLPTR; if (!config.empty()) { std::string configProp = cmSystemTools::UpperCase(config); @@ -3178,8 +3204,8 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, configPostfix = CM_NULLPTR; } } - const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); - const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact); + const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact); // Check for language-specific default prefix and suffix. std::string ll = this->GetLinkerLanguage(config); @@ -3223,14 +3249,15 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix ? targetPrefix : ""; // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); + outBase += this->GetOutputName(config, artifact); // Append the per-configuration postfix. outBase += configPostfix ? configPostfix : ""; // Name shared libraries with their version number on some platforms. if (const char* soversion = this->GetProperty("SOVERSION")) { - if (this->GetType() == cmStateEnums::SHARED_LIBRARY && !implib && + if (this->GetType() == cmStateEnums::SHARED_LIBRARY && + !isImportedLibraryArtifact && this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) { outBase += "-"; outBase += soversion; @@ -3252,7 +3279,8 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); std::vector<std::string> props; std::string configUpper = cmSystemTools::UpperCase(config); @@ -4404,26 +4432,31 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries( return iface.Exists ? &iface : CM_NULLPTR; } -std::string cmGeneratorTarget::GetDirectory(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetDirectory( + const std::string& config, cmStateEnums::ArtifactType artifact) const { if (this->IsImported()) { // Return the directory from which the target is imported. return cmSystemTools::GetFilenamePath( - this->Target->ImportedGetFullPath(config, implib)); + this->Target->ImportedGetFullPath(config, artifact)); } if (OutputInfo const* info = this->GetOutputInfo(config)) { // Return the directory in which the target will be built. - return implib ? info->ImpDir : info->OutDir; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return info->OutDir; + case cmStateEnums::ImportLibraryArtifact: + return info->ImpDir; + } } return ""; } -bool cmGeneratorTarget::UsesDefaultOutputDir(const std::string& config, - bool implib) const +bool cmGeneratorTarget::UsesDefaultOutputDir( + const std::string& config, cmStateEnums::ArtifactType artifact) const { std::string dir; - return this->ComputeOutputDir(config, implib, dir); + return this->ComputeOutputDir(config, artifact, dir); } cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( @@ -4457,8 +4490,10 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( i = this->OutputInfoMap.insert(entry).first; // Compute output directories. - this->ComputeOutputDir(config, false, info.OutDir); - this->ComputeOutputDir(config, true, info.ImpDir); + this->ComputeOutputDir(config, cmStateEnums::RuntimeBinaryArtifact, + info.OutDir); + this->ComputeOutputDir(config, cmStateEnums::ImportLibraryArtifact, + info.ImpDir); if (!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } @@ -4478,14 +4513,15 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( } bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, - bool implib, std::string& out) const + cmStateEnums::ArtifactType artifact, + std::string& out) const { bool usesDefaultOutputDir = false; std::string conf = config; // Look for a target property defining the target output directory // based on the target type. - std::string targetTypeName = this->GetOutputTargetType(implib); + std::string targetTypeName = this->GetOutputTargetType(artifact); const char* propertyName = CM_NULLPTR; std::string propertyNameStr = targetTypeName; if (!propertyNameStr.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 5b903de..3a0d23f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -203,9 +203,12 @@ public: /** Get the full path to the target according to the settings in its makefile and the configuration type. */ - std::string GetFullPath(const std::string& config = "", bool implib = false, - bool realname = false) const; - std::string NormalGetFullPath(const std::string& config, bool implib, + std::string GetFullPath( + const std::string& config = "", + cmStateEnums::ArtifactType artifact = cmStateEnums::RuntimeBinaryArtifact, + bool realname = false) const; + std::string NormalGetFullPath(const std::string& config, + cmStateEnums::ArtifactType artifact, bool realname) const; std::string NormalGetRealName(const std::string& config) const; @@ -233,7 +236,8 @@ public: /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** @return the Mac framework directory without the base. */ std::string GetFrameworkDirectory(const std::string& config, @@ -278,7 +282,8 @@ public: void GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** Append to @a base the bundle directory hierarchy up to a certain @a level * and return it. */ @@ -287,8 +292,8 @@ public: BundleDirectoryLevel level) const; /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config = CM_NULLPTR, - bool implib = false) const; + std::string GetMacContentDirectory( + const std::string& config, cmStateEnums::ArtifactType artifact) const; /** @return folder prefix for IDEs. */ std::string GetEffectiveFolderName() const; @@ -355,7 +360,7 @@ public: std::vector<cmGeneratorTarget*>& objlibs) const; std::string GetFullNameImported(const std::string& config, - bool implib) const; + cmStateEnums::ArtifactType artifact) const; /** Get source files common to all configurations and diagnose cases with per-config sources. Excludes sources added by a TARGET_OBJECTS @@ -415,7 +420,8 @@ public: subdirectory for that configuration. Otherwise just the canonical output directory is given. */ std::string GetDirectory(const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** Get the directory in which to place the target compiler .pdb file. If the configuration name is given then the generator will add its @@ -429,7 +435,8 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const std::string& config, bool implib) const; + bool UsesDefaultOutputDir(const std::string& config, + cmStateEnums::ArtifactType artifact) const; // Cache target output paths for each configuration. struct OutputInfo @@ -470,7 +477,8 @@ public: std::string GetCompilePDBPath(const std::string& config = "") const; // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; + std::string GetOutputName(const std::string& config, + cmStateEnums::ArtifactType artifact) const; void AddSource(const std::string& src); void AddTracedSources(std::vector<std::string> const& srcs); @@ -653,8 +661,9 @@ private: mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, + cmStateEnums::ArtifactType artifact) const; + void GetFullNameInternal(const std::string& config, + cmStateEnums::ArtifactType artifact, std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; @@ -662,7 +671,7 @@ private: mutable LinkClosureMapType LinkClosureMap; // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. - const char* GetOutputTargetType(bool implib) const; + const char* GetOutputTargetType(cmStateEnums::ArtifactType artifact) const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, std::string const& suffix, @@ -788,7 +797,8 @@ private: cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal( const std::string& config, const cmGeneratorTarget* head) const; - bool ComputeOutputDir(const std::string& config, bool implib, + bool ComputeOutputDir(const std::string& config, + cmStateEnums::ArtifactType artifact, std::string& out) const; typedef std::map<std::string, OutputInfo> OutputInfoMapType; @@ -800,7 +810,7 @@ private: void ComputeModuleDefinitionInfo(std::string const& config, ModuleDefinitionInfo& info) const; - typedef std::pair<std::string, bool> OutputNameKey; + typedef std::pair<std::string, cmStateEnums::ArtifactType> OutputNameKey; typedef std::map<OutputNameKey, std::string> OutputNameMapType; mutable OutputNameMapType OutputNameMap; mutable std::set<cmLinkItem> UtilityItems; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index a95d4ee..e61cbd9 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -983,8 +983,8 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { - outputs.push_back(this->ConvertToNinjaPath( - target->GetFullPath(configName, false, realname))); + outputs.push_back(this->ConvertToNinjaPath(target->GetFullPath( + configName, cmStateEnums::RuntimeBinaryArtifact, realname))); break; } case cmStateEnums::OBJECT_LIBRARY: diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6118c73..4213751 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1817,7 +1817,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, gtgt->GetType() == cmStateEnums::MODULE_LIBRARY || gtgt->GetType() == cmStateEnums::EXECUTABLE) { if (this->XcodeVersion >= 21) { - if (!gtgt->UsesDefaultOutputDir(configName, false)) { + if (!gtgt->UsesDefaultOutputDir(configName, + cmStateEnums::RuntimeBinaryArtifact)) { std::string pncdir = gtgt->GetDirectory(configName); buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", this->CreateString(pncdir)); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 6ecf42d..1827ed3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -103,7 +103,10 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( fromDirConfig += cmake::GetCMakeFilesDirectory(); fromDirConfig += "/CMakeRelink.dir/"; } else { - fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); + cmStateEnums::ArtifactType artifact = this->ImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + fromDirConfig = this->Target->GetDirectory(config, artifact); fromDirConfig += "/"; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7535ef4..f86c034 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1130,7 +1130,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n"; } - temp = target->GetDirectory(configName, true); + temp = + target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" @@ -1227,7 +1228,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\""; } - temp = target->GetDirectory(configName, true); + temp = + target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index e20fe50..3d7b60b 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -80,8 +80,10 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, !(isFortran && target->GetType() == cmStateEnums::SHARED_LIBRARY)) { return pcc; } - std::string outDir = target->GetDirectory(config, false); - std::string impDir = target->GetDirectory(config, true); + std::string outDir = + target->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact); + std::string impDir = + target->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); if (impDir == outDir) { return pcc; } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 493f474..a93b42d 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -21,6 +21,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" #include "cmake.h" @@ -332,7 +333,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } else { cmSystemTools::MakeDirectory(outpath.c_str()); if (!targetNameImport.empty()) { - outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory( + this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index cc8a6b3..e017b29 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -514,7 +514,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( cmSystemTools::MakeDirectory(outpath.c_str()); outpath += "/"; if (!targetNameImport.empty()) { - outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory( + this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index dd5cd7d..7acfb85 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -505,8 +505,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { - targetFullPathReal = - this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); + targetFullPathReal = this->GeneratorTarget->GetFullPath( + this->ConfigName, cmStateEnums::RuntimeBinaryArtifact, true); targetFullPathPDB = this->GeneratorTarget->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index edab2ba..cfc91bd 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -485,10 +485,9 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName)); - std::string targetOutputReal = - this->ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/false, - /*realname=*/true)); + std::string targetOutputReal = this->ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true)); cmakeCommand += targetOutputReal; cmakeCommand += " || true"; linkCmds.push_back(cmakeCommand); @@ -580,9 +579,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() std::string const targetOutputReal = ConvertToNinjaPath( genTarget.ObjectDirectory + "cmake_device_link" + objExt); - std::string const targetOutputImplib = - ConvertToNinjaPath(genTarget.GetFullPath(cfgName, - /*implib=*/true)); + std::string const targetOutputImplib = ConvertToNinjaPath( + genTarget.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact)); this->DeviceLinkObject = targetOutputReal; @@ -753,13 +751,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName)); - std::string targetOutputReal = - ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/false, - /*realname=*/true)); - std::string targetOutputImplib = - ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/true)); + std::string targetOutputReal = ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true)); + std::string targetOutputImplib = ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact)); if (gt.IsAppBundleOnApple()) { // Create the app bundle diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index c09feef..332fa83 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -7,6 +7,7 @@ #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -213,8 +214,8 @@ std::string cmOSXBundleGenerator::InitMacOSXContentDirectory( { // Construct the full path to the content subdirectory. - std::string macdir = this->GT->GetMacContentDirectory(this->ConfigName, - /*implib*/ false); + std::string macdir = this->GT->GetMacContentDirectory( + this->ConfigName, cmStateEnums::RuntimeBinaryArtifact); macdir += "/"; macdir += pkgloc; cmSystemTools::MakeDirectory(macdir.c_str()); diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index a5c1a23..8227ab7 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -763,9 +763,11 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, if (target->HaveWellDefinedOutputFiles()) { Json::Value artifacts = Json::arrayValue; - artifacts.append(target->GetFullPath(config, false)); + artifacts.append( + target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact)); if (target->IsDLLPlatform()) { - artifacts.append(target->GetFullPath(config, true)); + artifacts.append( + target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact)); const cmGeneratorTarget::OutputInfo* output = target->GetOutputInfo(config); if (output && !output->PdbDir.empty()) { diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h index b2b12b4..7d6158e 100644 --- a/Source/cmStateTypes.h +++ b/Source/cmStateTypes.h @@ -53,6 +53,12 @@ enum CacheEntryType STATIC, UNINITIALIZED }; + +enum ArtifactType +{ + RuntimeBinaryArtifact, + ImportLibraryArtifact +}; } #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0b1bb06..bda1d95 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -35,7 +35,7 @@ const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>( { static std::string loc; if (tgt->IsImported()) { - loc = tgt->ImportedGetFullPath("", false); + loc = tgt->ImportedGetFullPath("", cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -54,7 +54,8 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>( { static std::string loc; if (tgt->IsImported()) { - loc = tgt->ImportedGetFullPath(config, false); + loc = + tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -63,7 +64,7 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>( gg->CreateGenerationObjects(); } cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName()); - loc = gt->GetFullPath(config, false); + loc = gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -1294,58 +1295,88 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const return cmSystemTools::IsOn(this->GetProperty(prop)); } -const char* cmTarget::GetSuffixVariableInternal(bool implib) const +const char* cmTarget::GetSuffixVariableInternal( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_SUFFIX"; case cmStateEnums::SHARED_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_SHARED_LIBRARY_SUFFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_LIBRARY_SUFFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; case cmStateEnums::MODULE_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_SHARED_MODULE_SUFFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_MODULE_SUFFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; case cmStateEnums::EXECUTABLE: - return (implib - ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - // Android GUI application packages store the native - // binary as a shared library. - : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") - ? "CMAKE_SHARED_LIBRARY_SUFFIX" - : "CMAKE_EXECUTABLE_SUFFIX")); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Android GUI application packages store the native + // binary as a shared library. + return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + ? "CMAKE_SHARED_LIBRARY_SUFFIX" + : "CMAKE_EXECUTABLE_SUFFIX"); + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; default: break; } return ""; } -const char* cmTarget::GetPrefixVariableInternal(bool implib) const +const char* cmTarget::GetPrefixVariableInternal( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_PREFIX"; case cmStateEnums::SHARED_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" - : "CMAKE_SHARED_LIBRARY_PREFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_LIBRARY_PREFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; case cmStateEnums::MODULE_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" - : "CMAKE_SHARED_MODULE_PREFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_MODULE_PREFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; case cmStateEnums::EXECUTABLE: - return (implib - ? "CMAKE_IMPORT_LIBRARY_PREFIX" - // Android GUI application packages store the native - // binary as a shared library. - : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") - ? "CMAKE_SHARED_LIBRARY_PREFIX" - : "")); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Android GUI application packages store the native + // binary as a shared library. + return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + ? "CMAKE_SHARED_LIBRARY_PREFIX" + : ""); + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; default: break; } return ""; } -std::string cmTarget::ImportedGetFullPath(const std::string& config, - bool pimplib) const +std::string cmTarget::ImportedGetFullPath( + const std::string& config, cmStateEnums::ArtifactType artifact) const { assert(this->IsImported()); @@ -1364,32 +1395,37 @@ std::string cmTarget::ImportedGetFullPath(const std::string& config, if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetMappedConfig(desired_config, &loc, &imp, suffix)) { - if (!pimplib) { - if (loc) { - result = loc; - } else { - std::string impProp = "IMPORTED_LOCATION"; - impProp += suffix; - if (const char* config_location = this->GetProperty(impProp)) { - result = config_location; - } else if (const char* location = - this->GetProperty("IMPORTED_LOCATION")) { - result = location; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + if (loc) { + result = loc; + } else { + std::string impProp = "IMPORTED_LOCATION"; + impProp += suffix; + if (const char* config_location = this->GetProperty(impProp)) { + result = config_location; + } else if (const char* location = + this->GetProperty("IMPORTED_LOCATION")) { + result = location; + } } - } - } else { - if (imp) { - result = imp; - } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || - this->IsExecutableWithExports()) { - std::string impProp = "IMPORTED_IMPLIB"; - impProp += suffix; - if (const char* config_implib = this->GetProperty(impProp)) { - result = config_implib; - } else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) { - result = implib; + break; + + case cmStateEnums::ImportLibraryArtifact: + if (imp) { + result = imp; + } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->IsExecutableWithExports()) { + std::string impProp = "IMPORTED_IMPLIB"; + impProp += suffix; + if (const char* config_implib = this->GetProperty(impProp)) { + result = config_implib; + } else if (const char* implib = + this->GetProperty("IMPORTED_IMPLIB")) { + result = implib; + } } - } + break; } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c67143a..1f00c01 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -267,11 +267,13 @@ public: }; std::string ImportedGetFullPath(const std::string& config, - bool implib) const; + cmStateEnums::ArtifactType artifact) const; private: - const char* GetSuffixVariableInternal(bool implib) const; - const char* GetPrefixVariableInternal(bool implib) const; + const char* GetSuffixVariableInternal( + cmStateEnums::ArtifactType artifact) const; + const char* GetPrefixVariableInternal( + cmStateEnums::ArtifactType artifact) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f0f04a8..18b93f6 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1051,8 +1051,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( std::string postfixName = cmSystemTools::UpperCase(config); postfixName += "_POSTFIX"; - std::string assemblyName = - this->GeneratorTarget->GetOutputName(config, false); + std::string assemblyName = this->GeneratorTarget->GetOutputName( + config, cmStateEnums::RuntimeBinaryArtifact); if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) { assemblyName += postfix; } @@ -3014,8 +3014,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); pdb += "/"; pdb += targetNamePDB; - std::string imLib = - this->GeneratorTarget->GetDirectory(config.c_str(), true); + std::string imLib = this->GeneratorTarget->GetDirectory( + config.c_str(), cmStateEnums::ImportLibraryArtifact); imLib += "/"; imLib += targetNameImport; |