diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2019-02-08 05:27:00 (GMT) |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2019-02-11 18:44:24 (GMT) |
commit | fc8b90af2c7f35f770b3167de2dd4c632b3042ea (patch) | |
tree | 018c561eea618044d60bb2530a563f534934da80 /Source | |
parent | 8a1d25afdf92cabab88598cc9b9e5a9fb2a9493b (diff) | |
download | CMake-fc8b90af2c7f35f770b3167de2dd4c632b3042ea.zip CMake-fc8b90af2c7f35f770b3167de2dd4c632b3042ea.tar.gz CMake-fc8b90af2c7f35f770b3167de2dd4c632b3042ea.tar.bz2 |
Create and use `cmGeneratorTarget::Names`
Rather than taking a number of out parameters for the various names,
create a structure that is reused for both `GetLibraryNames` and
`GetExecutableNames`. Replace uses according to the new interface.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 129 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 18 | ||||
-rw-r--r-- | Source/cmGhsMultiTargetGenerator.cxx | 26 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 100 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 31 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 32 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 49 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.h | 8 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 36 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.h | 9 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 19 |
11 files changed, 187 insertions, 270 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 54cfd3a..6f5e9bd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1617,13 +1617,7 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const return ""; } // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; + return this->GetLibraryNames(config).SharedObject; } static bool shouldAddFullLevel(cmGeneratorTarget::BundleDirectoryLevel level) @@ -3394,17 +3388,13 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); // Get the names. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; + cmGeneratorTarget::Names targetNames; if (this->GetType() == cmStateEnums::EXECUTABLE) { - this->GetExecutableNames(name, realName, impName, pdbName, config); + targetNames = this->GetExecutableNames(config); } else if (this->GetType() == cmStateEnums::STATIC_LIBRARY || this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::MODULE_LIBRARY) { - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); + targetNames = this->GetLibraryNames(config); } else { return; } @@ -3415,34 +3405,34 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const // Add each name. std::string f; - if (!name.empty()) { + if (!targetNames.Output.empty()) { f = dir; f += "/"; - f += name; + f += targetNames.Output; gg->AddToManifest(f); } - if (!soName.empty()) { + if (!targetNames.SharedObject.empty()) { f = dir; f += "/"; - f += soName; + f += targetNames.SharedObject; gg->AddToManifest(f); } - if (!realName.empty()) { + if (!targetNames.Real.empty()) { f = dir; f += "/"; - f += realName; + f += targetNames.Real; gg->AddToManifest(f); } - if (!pdbName.empty()) { + if (!targetNames.PDB.empty()) { f = dir; f += "/"; - f += pdbName; + f += targetNames.PDB; gg->AddToManifest(f); } - if (!impName.empty()) { + if (!targetNames.ImportLibrary.empty()) { f = this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); f += "/"; - f += impName; + f += targetNames.ImportLibrary; gg->AddToManifest(f); } } @@ -3520,29 +3510,17 @@ std::string cmGeneratorTarget::NormalGetRealName( if (this->GetType() == cmStateEnums::EXECUTABLE) { // Compute the real name that will be built. - std::string name; - std::string realName; - std::string impName; - std::string pdbName; - this->GetExecutableNames(name, realName, impName, pdbName, config); - return realName; + return this->GetExecutableNames(config).Real; } // Compute the real name that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return realName; -} - -void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const + return this->GetLibraryNames(config).Real; +} + +cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames( + const std::string& config) const { + cmGeneratorTarget::Names targetNames; + // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. @@ -3550,7 +3528,6 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, std::string msg = "GetLibraryNames called on imported target: "; msg += this->GetName(); this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR, msg); - return; } // Check for library version properties. @@ -3576,50 +3553,51 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, // Get the components of the library name. std::string prefix; - std::string base; std::string suffix; this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, - prefix, base, suffix); + prefix, targetNames.Base, suffix); // The library name. - name = prefix + base + suffix; + targetNames.Output = prefix + targetNames.Base + suffix; if (this->IsFrameworkOnApple()) { - realName = prefix; + targetNames.Real = prefix; if (!this->Makefile->PlatformIsAppleEmbedded()) { - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; + targetNames.Real += "Versions/"; + targetNames.Real += this->GetFrameworkVersion(); + targetNames.Real += "/"; } - realName += base; - soName = realName; + targetNames.Real += targetNames.Base; + targetNames.SharedObject = targetNames.Real; } else { // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, name, soversion); + this->ComputeVersionedName(targetNames.SharedObject, prefix, + targetNames.Base, suffix, targetNames.Output, + soversion); // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, name, version); + this->ComputeVersionedName(targetNames.Real, prefix, targetNames.Base, + suffix, targetNames.Output, version); } // The import library name. if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::MODULE_LIBRARY) { - impName = + targetNames.ImportLibrary = this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); - } else { - impName.clear(); } // The program database file name. - pdbName = this->GetPDBName(config); + targetNames.PDB = this->GetPDBName(config); + + return targetNames; } -void cmGeneratorTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const +cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames( + const std::string& config) const { + cmGeneratorTarget::Names targetNames; + // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. @@ -3644,34 +3622,35 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, // Get the components of the executable name. std::string prefix; - std::string base; std::string suffix; this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, - prefix, base, suffix); + prefix, targetNames.Base, suffix); // The executable name. - name = prefix + base + suffix; + targetNames.Output = prefix + targetNames.Base + suffix; // The executable's real name on disk. #if defined(__CYGWIN__) - realName = prefix + base; + targetNames.Real = prefix + targetNames.Base; #else - realName = name; + targetNames.Real = targetNames.Output; #endif if (version) { - realName += "-"; - realName += version; + targetNames.Real += "-"; + targetNames.Real += version; } #if defined(__CYGWIN__) - realName += suffix; + targetNames.Real += suffix; #endif // The import library name. - impName = + targetNames.ImportLibrary = this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); // The program database file name. - pdbName = this->GetPDBName(config); + targetNames.PDB = this->GetPDBName(config); + + return targetNames; } std::string cmGeneratorTarget::GetFullNameInternal( diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 59d38af..bc966e1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -568,19 +568,25 @@ public: void GetAutoUicOptions(std::vector<std::string>& result, const std::string& config) const; + struct Names + { + std::string Base; + std::string Output; + std::string Real; + std::string ImportLibrary; + std::string PDB; + std::string SharedObject; + }; + /** Get the names of the executable needed to generate a build rule that takes into account executable version numbers. This should be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, std::string& pdbName, - const std::string& config) const; + Names GetExecutableNames(const std::string& config) const; /** Get the names of the library needed to generate a build rule that takes into account shared library version numbers. This should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; + Names GetLibraryNames(const std::string& config) const; /** * Compute whether this target must be relinked before installing. diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 08441a8..c63e01a 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -40,12 +40,8 @@ void cmGhsMultiTargetGenerator::Generate() switch (this->GeneratorTarget->GetType()) { case cmStateEnums::EXECUTABLE: { // Get the name of the executable to generate. - std::string targetName; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetExecutableNames( - targetName, this->TargetNameReal, targetNameImport, targetNamePDB, - this->ConfigName); + this->TargetNameReal = + this->GeneratorTarget->GetExecutableNames(this->ConfigName).Real; if (cmGhsMultiTargetGenerator::DetermineIfIntegrityApp()) { this->TagType = GhsMultiGpj::INTERGRITY_APPLICATION; } else { @@ -54,13 +50,8 @@ void cmGhsMultiTargetGenerator::Generate() break; } case cmStateEnums::STATIC_LIBRARY: { - std::string targetName; - std::string targetNameSO; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetLibraryNames( - targetName, targetNameSO, this->TargetNameReal, targetNameImport, - targetNamePDB, this->ConfigName); + this->TargetNameReal = + this->GeneratorTarget->GetLibraryNames(this->ConfigName).Real; this->TagType = GhsMultiGpj::LIBRARY; break; } @@ -71,13 +62,8 @@ void cmGhsMultiTargetGenerator::Generate() return; } case cmStateEnums::OBJECT_LIBRARY: { - std::string targetName; - std::string targetNameSO; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetLibraryNames( - targetName, targetNameSO, this->TargetNameReal, targetNameImport, - targetNamePDB, this->ConfigName); + this->TargetNameReal = + this->GeneratorTarget->GetLibraryNames(this->ConfigName).Real; this->TagType = GhsMultiGpj::SUBPROJECT; break; } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 5cee9d3..7053e99 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -123,19 +123,15 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); - std::string targetName; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - this->Target->GetExecutableNames(targetName, targetNameReal, - targetNameImport, targetNamePDB, config); + cmGeneratorTarget::Names targetNames = + this->Target->GetExecutableNames(config); if (this->ImportLibrary) { - std::string from1 = fromDirConfig + targetNameImport; - std::string to1 = toDir + targetNameImport; + std::string from1 = fromDirConfig + targetNames.ImportLibrary; + std::string to1 = toDir + targetNames.ImportLibrary; filesFrom.push_back(std::move(from1)); filesTo.push_back(std::move(to1)); std::string targetNameImportLib; - if (this->Target->GetImplibGNUtoMS(config, targetNameImport, + if (this->Target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); filesTo.push_back(toDir + targetNameImportLib); @@ -144,8 +140,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( // An import library looks like a static library. type = cmInstallType_STATIC_LIBRARY; } else { - std::string from1 = fromDirConfig + targetName; - std::string to1 = toDir + targetName; + std::string from1 = fromDirConfig + targetNames.Output; + std::string to1 = toDir + targetNames.Output; // Handle OSX Bundles. if (this->Target->IsAppBundleOnApple()) { @@ -170,12 +166,12 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( if (!mf->PlatformIsAppleEmbedded()) { to1 += "Contents/MacOS/"; } - to1 += targetName; + to1 += targetNames.Output; } else { // Tweaks apply to the real file, so list it first. - if (targetNameReal != targetName) { - std::string from2 = fromDirConfig + targetNameReal; - std::string to2 = toDir += targetNameReal; + if (targetNames.Real != targetNames.Output) { + std::string from2 = fromDirConfig + targetNames.Real; + std::string to2 = toDir += targetNames.Real; filesFrom.push_back(std::move(from2)); filesTo.push_back(std::move(to2)); } @@ -185,23 +181,18 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( filesTo.push_back(std::move(to1)); } } else { - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, - targetNameImport, targetNamePDB, config); + cmGeneratorTarget::Names targetNames = + this->Target->GetLibraryNames(config); if (this->ImportLibrary) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); - std::string from1 = fromDirConfig + targetNameImport; - std::string to1 = toDir + targetNameImport; + std::string from1 = fromDirConfig + targetNames.ImportLibrary; + std::string to1 = toDir + targetNames.ImportLibrary; filesFrom.push_back(std::move(from1)); filesTo.push_back(std::move(to1)); std::string targetNameImportLib; - if (this->Target->GetImplibGNUtoMS(config, targetNameImport, + if (this->Target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); filesTo.push_back(toDir + targetNameImportLib); @@ -243,11 +234,11 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( type = cmInstallType_DIRECTORY; literal_args += " USE_SOURCE_PERMISSIONS"; - std::string from1 = fromDirConfig + targetName; + std::string from1 = fromDirConfig + targetNames.Output; from1 = cmSystemTools::GetFilenamePath(from1); // Tweaks apply to the binary inside the bundle. - std::string to1 = toDir + targetNameReal; + std::string to1 = toDir + targetNames.Real; filesFrom.push_back(std::move(from1)); filesTo.push_back(std::move(to1)); @@ -256,10 +247,11 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( type = cmInstallType_DIRECTORY; literal_args += " USE_SOURCE_PERMISSIONS"; - std::string targetNameBase = targetName.substr(0, targetName.find('/')); + std::string targetNameBase = + targetNames.Output.substr(0, targetNames.Output.find('/')); std::string from1 = fromDirConfig + targetNameBase; - std::string to1 = toDir + targetName; + std::string to1 = toDir + targetNames.Output; filesFrom.push_back(std::move(from1)); filesTo.push_back(std::move(to1)); @@ -267,25 +259,26 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( bool haveNamelink = false; // Library link name. - std::string fromName = fromDirConfig + targetName; - std::string toName = toDir + targetName; + std::string fromName = fromDirConfig + targetNames.Output; + std::string toName = toDir + targetNames.Output; // Library interface name. std::string fromSOName; std::string toSOName; - if (targetNameSO != targetName) { + if (targetNames.SharedObject != targetNames.Output) { haveNamelink = true; - fromSOName = fromDirConfig + targetNameSO; - toSOName = toDir + targetNameSO; + fromSOName = fromDirConfig + targetNames.SharedObject; + toSOName = toDir + targetNames.SharedObject; } // Library implementation name. std::string fromRealName; std::string toRealName; - if (targetNameReal != targetName && targetNameReal != targetNameSO) { + if (targetNames.Real != targetNames.Output && + targetNames.Real != targetNames.SharedObject) { haveNamelink = true; - fromRealName = fromDirConfig + targetNameReal; - toRealName = toDir + targetNameReal; + fromRealName = fromDirConfig + targetNames.Real; + toRealName = toDir + targetNames.Real; } // Add the names based on the current namelink mode. @@ -416,48 +409,37 @@ std::string cmInstallTargetGenerator::GetInstallFilename( std::string fname; // Compute the name of the library. if (target->GetType() == cmStateEnums::EXECUTABLE) { - std::string targetName; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, targetNameImport, - targetNamePDB, config); + cmGeneratorTarget::Names targetNames = target->GetExecutableNames(config); if (nameType == NameImplib) { // Use the import library name. - if (!target->GetImplibGNUtoMS(config, targetNameImport, fname, + if (!target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { - fname = targetNameImport; + fname = targetNames.ImportLibrary; } } else if (nameType == NameReal) { // Use the canonical name. - fname = targetNameReal; + fname = targetNames.Real; } else { // Use the canonical name. - fname = targetName; + fname = targetNames.Output; } } else { - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, - targetNameImport, targetNamePDB, config); + cmGeneratorTarget::Names targetNames = target->GetLibraryNames(config); if (nameType == NameImplib) { // Use the import library name. - if (!target->GetImplibGNUtoMS(config, targetNameImport, fname, + if (!target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { - fname = targetNameImport; + fname = targetNames.ImportLibrary; } } else if (nameType == NameSO) { // Use the soname. - fname = targetNameSO; + fname = targetNames.SharedObject; } else if (nameType == NameReal) { // Use the real name. - fname = targetNameReal; + fname = targetNames.Real; } else { // Use the canonical name. - fname = targetName; + fname = targetNames.Output; } } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index b809be4..9f18e8f 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1043,13 +1043,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( } case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { - std::string targetName; - std::string targetNameSO; - std::string targetNameFull; - std::string targetNameImport; - std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameFull, - targetNameImport, targetNamePDB, configName); + cmGeneratorTarget::Names targetNames = + target->GetLibraryNames(configName); // Compute the link library and directory information. cmComputeLinkInformation* pcli = target->GetLinkInformation(configName); @@ -1085,7 +1080,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\"\n"; temp = target->GetDirectory(configName); temp += "/"; - temp += targetNameFull; + temp += targetNames.Output; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; this->WriteTargetVersionAttribute(fout, target); @@ -1095,7 +1090,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\"\n"; temp = target->GetPDBDirectory(configName); temp += "/"; - temp += targetNamePDB; + temp += targetNames.PDB; fout << "\t\t\t\tProgramDatabaseFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; if (targetOptions.IsDebug()) { @@ -1118,7 +1113,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( temp = target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; - temp += targetNameImport; + temp += targetNames.ImportLibrary; fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\""; if (this->FortranProject) { @@ -1127,12 +1122,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "/>\n"; } break; case cmStateEnums::EXECUTABLE: { - std::string targetName; - std::string targetNameFull; - std::string targetNameImport; - std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameFull, targetNameImport, - targetNamePDB, configName); + cmGeneratorTarget::Names targetNames = + target->GetExecutableNames(configName); // Compute the link library and directory information. cmComputeLinkInformation* pcli = target->GetLinkInformation(configName); @@ -1170,7 +1161,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\"\n"; temp = target->GetDirectory(configName); temp += "/"; - temp += targetNameFull; + temp += targetNames.Output; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; this->WriteTargetVersionAttribute(fout, target); @@ -1180,8 +1171,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\"\n"; std::string path = this->ConvertToXMLOutputPathSingle( target->GetPDBDirectory(configName).c_str()); - fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/" << targetNamePDB - << "\"\n"; + fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/" + << targetNames.PDB << "\"\n"; if (targetOptions.IsDebug()) { fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n"; } @@ -1216,7 +1207,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( temp = target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; - temp += targetNameImport; + temp += targetNames.ImportLibrary; fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n"; break; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e8ae5ae..572270a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -31,9 +31,8 @@ cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator( : cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->GeneratorTarget->GetExecutableNames( - this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, - this->TargetNamePDB, this->ConfigName); + this->TargetNames = + this->GeneratorTarget->GetExecutableNames(this->ConfigName); this->OSXBundleGenerator = new cmOSXBundleGenerator(target, this->ConfigName); @@ -305,18 +304,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::vector<std::string> commands; // Get the name of the executable to generate. - std::string targetName; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetExecutableNames(targetName, targetNameReal, - targetNameImport, targetNamePDB, - this->ConfigName); + cmGeneratorTarget::Names targetNames = + this->GeneratorTarget->GetExecutableNames(this->ConfigName); // Construct the full path version of the names. std::string outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); if (this->GeneratorTarget->IsAppBundleOnApple()) { - this->OSXBundleGenerator->CreateAppBundle(targetName, outpath); + this->OSXBundleGenerator->CreateAppBundle(targetNames.Output, outpath); } outpath += "/"; std::string outpathImp; @@ -326,12 +320,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); outpath += "/"; - if (!targetNameImport.empty()) { + if (!targetNames.ImportLibrary.empty()) { outpathImp = outpath; } } else { cmSystemTools::MakeDirectory(outpath); - if (!targetNameImport.empty()) { + if (!targetNames.ImportLibrary.empty()) { outpathImp = this->GeneratorTarget->GetDirectory( this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp); @@ -348,10 +342,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmSystemTools::MakeDirectory(pdbOutputPath); pdbOutputPath += "/"; - std::string targetFullPath = outpath + targetName; - std::string targetFullPathReal = outpath + targetNameReal; - std::string targetFullPathPDB = pdbOutputPath + targetNamePDB; - std::string targetFullPathImport = outpathImp + targetNameImport; + std::string targetFullPath = outpath + targetNames.Output; + std::string targetFullPathReal = outpath + targetNames.Real; + std::string targetFullPathPDB = pdbOutputPath + targetNames.PDB; + std::string targetFullPathImport = outpathImp + targetNames.ImportLibrary; std::string targetOutPathPDB = this->LocalGenerator->ConvertToOutputFormat( targetFullPathPDB, cmOutputConverter::SHELL); // Convert to the output path to use in constructing commands. @@ -468,11 +462,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath + ".manifest")); #endif - if (targetNameReal != targetName) { + if (this->TargetNames.Real != this->TargetNames.Output) { exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal)); } - if (!targetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport)); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 5a1ef4e..ed2fd68 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -32,9 +32,8 @@ cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator( { this->CustomCommandDriver = OnDepends; if (this->GeneratorTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - this->GeneratorTarget->GetLibraryNames( - this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, - this->TargetNameImport, this->TargetNamePDB, this->ConfigName); + this->TargetNames = + this->GeneratorTarget->GetLibraryNames(this->ConfigName); } this->OSXBundleGenerator = @@ -489,25 +488,20 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // Construct the name of the library. - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, - targetNameReal, targetNameImport, - targetNamePDB, this->ConfigName); + this->GeneratorTarget->GetLibraryNames(this->ConfigName); // Construct the full path version of the names. std::string outpath; std::string outpathImp; if (this->GeneratorTarget->IsFrameworkOnApple()) { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); - this->OSXBundleGenerator->CreateFramework(targetName, outpath); + this->OSXBundleGenerator->CreateFramework(this->TargetNames.Output, + outpath); outpath += "/"; } else if (this->GeneratorTarget->IsCFBundleOnApple()) { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); - this->OSXBundleGenerator->CreateCFBundle(targetName, outpath); + this->OSXBundleGenerator->CreateCFBundle(this->TargetNames.Output, + outpath); outpath += "/"; } else if (relink) { outpath = this->Makefile->GetCurrentBinaryDirectory(); @@ -515,14 +509,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); outpath += "/"; - if (!targetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { outpathImp = outpath; } } else { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); cmSystemTools::MakeDirectory(outpath); outpath += "/"; - if (!targetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { outpathImp = this->GeneratorTarget->GetDirectory( this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp); @@ -539,11 +533,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( cmSystemTools::MakeDirectory(pdbOutputPath); pdbOutputPath += "/"; - std::string targetFullPath = outpath + targetName; - std::string targetFullPathPDB = pdbOutputPath + targetNamePDB; - std::string targetFullPathSO = outpath + targetNameSO; - std::string targetFullPathReal = outpath + targetNameReal; - std::string targetFullPathImport = outpathImp + targetNameImport; + std::string targetFullPath = outpath + this->TargetNames.Output; + std::string targetFullPathPDB = pdbOutputPath + this->TargetNames.PDB; + std::string targetFullPathSO = outpath + this->TargetNames.SharedObject; + std::string targetFullPathReal = outpath + this->TargetNames.Real; + std::string targetFullPathImport = + outpathImp + this->TargetNames.ImportLibrary; // Construct the output path version of the names for use in command // arguments. @@ -616,15 +611,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( commands1.clear(); } - if (targetName != targetNameReal) { + if (this->TargetNames.Output != this->TargetNames.Real) { libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath)); } - if (targetNameSO != targetNameReal && targetNameSO != targetName) { + if (this->TargetNames.SharedObject != this->TargetNames.Real && + this->TargetNames.SharedObject != this->TargetNames.Output) { libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO)); } - if (!targetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport)); @@ -820,7 +816,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( vars.ObjectsQuoted = buildObjs.c_str(); if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); - vars.TargetSOName = targetNameSO.c_str(); + vars.TargetSOName = this->TargetNames.SharedObject.c_str(); } vars.LinkFlags = linkFlags.c_str(); @@ -981,10 +977,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Compute the list of outputs. std::vector<std::string> outputs(1, targetFullPathReal); - if (targetNameSO != targetNameReal) { + if (this->TargetNames.SharedObject != this->TargetNames.Real) { outputs.push_back(targetFullPathSO); } - if (targetName != targetNameSO && targetName != targetNameReal) { + if (this->TargetNames.Output != this->TargetNames.SharedObject && + this->TargetNames.Output != this->TargetNames.Real) { outputs.push_back(targetFullPath); } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 529b4db..c053d5b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -12,12 +12,12 @@ #include <vector> #include "cmCommonTargetGenerator.h" +#include "cmGeneratorTarget.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmOSXBundleGenerator.h" class cmCustomCommandGenerator; class cmGeneratedFileStream; -class cmGeneratorTarget; class cmGlobalUnixMakefileGenerator3; class cmLinkLineComputer; class cmOutputConverter; @@ -231,11 +231,7 @@ protected: bool in_help = false); // Target name info. - std::string TargetNameOut; - std::string TargetNameSO; - std::string TargetNameReal; - std::string TargetNameImport; - std::string TargetNamePDB; + cmGeneratorTarget::Names TargetNames; // macOS content info. std::set<std::string> MacContentFolders; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index cbc0103..3874f48 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -41,13 +41,10 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( { this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmStateEnums::EXECUTABLE) { - this->GetGeneratorTarget()->GetExecutableNames( - this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, - this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); + this->TargetNames = this->GetGeneratorTarget()->GetExecutableNames( + GetLocalGenerator()->GetConfigName()); } else { - this->GetGeneratorTarget()->GetLibraryNames( - this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, - this->TargetNameImport, this->TargetNamePDB, + this->TargetNames = this->GetGeneratorTarget()->GetLibraryNames( GetLocalGenerator()->GetConfigName()); } @@ -395,7 +392,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) /*generator*/ false); } - if (this->TargetNameOut != this->TargetNameReal && + if (this->TargetNames.Output != this->TargetNames.Real && !this->GetGeneratorTarget()->IsFrameworkOnApple()) { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( @@ -676,7 +673,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage); - vars["SONAME"] = this->TargetNameSO; + vars["SONAME"] = this->TargetNames.SharedObject; if (targetType == cmStateEnums::SHARED_LIBRARY) { std::string install_dir = this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); @@ -687,7 +684,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() } } - if (!this->TargetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { const std::string impLibPath = localGen.ConvertToOutputFormat( targetOutputImplib, cmOutputConverter::SHELL); vars["TARGET_IMPLIB"] = impLibPath; @@ -749,24 +746,25 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (gt.IsAppBundleOnApple()) { // Create the app bundle std::string outpath = gt.GetDirectory(cfgName); - this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath); + this->OSXBundleGenerator->CreateAppBundle(this->TargetNames.Output, + outpath); // Calculate the output path targetOutput = outpath; targetOutput += "/"; - targetOutput += this->TargetNameOut; + targetOutput += this->TargetNames.Output; targetOutput = this->ConvertToNinjaPath(targetOutput); targetOutputReal = outpath; targetOutputReal += "/"; - targetOutputReal += this->TargetNameReal; + targetOutputReal += this->TargetNames.Real; targetOutputReal = this->ConvertToNinjaPath(targetOutputReal); } else if (gt.IsFrameworkOnApple()) { // Create the library framework. - this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, + this->OSXBundleGenerator->CreateFramework(this->TargetNames.Output, gt.GetDirectory(cfgName)); } else if (gt.IsCFBundleOnApple()) { // Create the core foundation bundle. - this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, + this->OSXBundleGenerator->CreateCFBundle(this->TargetNames.Output, gt.GetDirectory(cfgName)); } @@ -864,7 +862,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); - vars["SONAME"] = this->TargetNameSO; + vars["SONAME"] = this->TargetNames.SharedObject; if (targetType == cmStateEnums::SHARED_LIBRARY) { std::string install_dir = this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); @@ -877,7 +875,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmNinjaDeps byproducts; - if (!this->TargetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { const std::string impLibPath = localGen.ConvertToOutputFormat( targetOutputImplib, cmOutputConverter::SHELL); vars["TARGET_IMPLIB"] = impLibPath; @@ -1037,8 +1035,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() emptyDeps, emptyDeps, symlinkVars); } else { cmNinjaDeps symlinks; - std::string const soName = - this->ConvertToNinjaPath(this->GetTargetFilePath(this->TargetNameSO)); + std::string const soName = this->ConvertToNinjaPath( + this->GetTargetFilePath(this->TargetNames.SharedObject)); // If one link has to be created. if (targetOutputReal == soName || targetOutput == soName) { symlinkVars["SONAME"] = soName; @@ -1056,7 +1054,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } // Add aliases for the file name and the target name. - globalGen.AddTargetAlias(this->TargetNameOut, >); + globalGen.AddTargetAlias(this->TargetNames.Output, >); globalGen.AddTargetAlias(this->GetTargetName(), >); } diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 01cc881..14991a2 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -5,13 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmGeneratorTarget.h" #include "cmNinjaTargetGenerator.h" #include <string> #include <vector> -class cmGeneratorTarget; - class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator { public: @@ -40,11 +39,7 @@ private: private: // Target name info. - std::string TargetNameOut; - std::string TargetNameSO; - std::string TargetNameReal; - std::string TargetNameImport; - std::string TargetNamePDB; + cmGeneratorTarget::Names TargetNames; std::string TargetLinkLanguage; std::string DeviceLinkObject; }; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8e08417..00a2d74 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3439,18 +3439,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkDirs.push_back("%(AdditionalLibraryDirectories)"); linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs); - std::string targetName; - std::string targetNameSO; - std::string targetNameFull; - std::string targetNameImport; - std::string targetNamePDB; + cmGeneratorTarget::Names targetNames; if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { - this->GeneratorTarget->GetExecutableNames( - targetName, targetNameFull, targetNameImport, targetNamePDB, config); + targetNames = this->GeneratorTarget->GetExecutableNames(config); } else { - this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, - targetNameFull, targetNameImport, - targetNamePDB, config); + targetNames = this->GeneratorTarget->GetLibraryNames(config); } if (this->MSTools) { @@ -3491,11 +3484,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string pdb = this->GeneratorTarget->GetPDBDirectory(config); pdb += "/"; - pdb += targetNamePDB; + pdb += targetNames.PDB; std::string imLib = this->GeneratorTarget->GetDirectory( config, cmStateEnums::ImportLibraryArtifact); imLib += "/"; - imLib += targetNameImport; + imLib += targetNames.ImportLibrary; linkOptions.AddFlag("ImportLibrary", imLib); linkOptions.AddFlag("ProgramDataBaseFile", pdb); @@ -3519,7 +3512,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib"); } } else if (this->NsightTegra) { - linkOptions.AddFlag("SoName", targetNameSO); + linkOptions.AddFlag("SoName", targetNames.SharedObject); } linkOptions.Parse(flags); |