diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-06-15 18:27:33 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-06-15 18:27:33 (GMT) |
commit | 0ef8da2a53a9198ec2cf922f8b265d54f7432352 (patch) | |
tree | 242527ac5d28b23be5a55c03cdee4af6296917da /Source | |
parent | 82375189948c5740d57415c305534500984fc14f (diff) | |
download | CMake-0ef8da2a53a9198ec2cf922f8b265d54f7432352.zip CMake-0ef8da2a53a9198ec2cf922f8b265d54f7432352.tar.gz CMake-0ef8da2a53a9198ec2cf922f8b265d54f7432352.tar.bz2 |
STYLE: remove code duplication between PrepareScriptReference and
GetScriptReference, and make the logic for getting the filename public, so
it can be used e.g. for exporting
Alex
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 153 |
1 files changed, 61 insertions, 92 deletions
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 1205f5c..011603c 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -189,6 +189,63 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) } //---------------------------------------------------------------------------- +std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, + const char* config, + bool implib, + bool useSOName) +{ + std::string fname; + // Compute the name of the library. + if(target->GetType() == cmTarget::EXECUTABLE) + { + std::string targetName; + std::string targetNameReal; + std::string targetNameImport; + std::string targetNamePDB; + target->GetExecutableNames(targetName, targetNameReal, + targetNameImport, targetNamePDB, + config); + if(implib) + { + // Use the import library name. + fname = targetNameImport; + } + else + { + // Use the canonical name. + fname = targetName; + } + } + else + { + std::string targetName; + std::string targetNameSO; + std::string targetNameReal; + std::string targetNameImport; + std::string targetNamePDB; + target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + targetNameImport, targetNamePDB, config); + if(implib) + { + // Use the import library name. + fname = targetNameImport; + } + else if(useSOName) + { + // Use the soname. + fname = targetNameSO; + } + else + { + // Use the canonical name. + fname = targetName; + } + } + + return fname; +} + +//---------------------------------------------------------------------------- void cmInstallTargetGenerator ::PrepareScriptReference(std::ostream& os, cmTarget* target, @@ -212,52 +269,8 @@ cmInstallTargetGenerator AppendDirectoryForConfig("", i->c_str(), "/", fname); } - // Compute the name of the library. - if(target->GetType() == cmTarget::EXECUTABLE) - { - std::string targetName; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, - targetNameImport, targetNamePDB, - i->c_str()); - if(this->ImportLibrary) - { - // Use the import library name. - fname += targetNameImport; - } - else - { - // Use the canonical name. - fname += targetName; - } - } - else - { - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, - targetNameImport, targetNamePDB, i->c_str()); - if(this->ImportLibrary) - { - // Use the import library name. - fname += targetNameImport; - } - else if(useSOName) - { - // Use the soname. - fname += targetNameSO; - } - else - { - // Use the canonical name. - fname += targetName; - } - } + fname += this->GetInstallFilename(target, i->c_str(), + this->ImportLibrary, useSOName); // Set a variable with the target name for this configuration. os << "SET(" << target->GetName() << "_" << place @@ -274,52 +287,8 @@ std::string cmInstallTargetGenerator::GetScriptReference(cmTarget* target, if(this->ConfigurationTypes->empty()) { // Reference the target by its one configuration name. - if(target->GetType() == cmTarget::EXECUTABLE) - { - std::string targetName; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, - targetNameImport, targetNamePDB, - this->ConfigurationName); - if(this->ImportLibrary) - { - // Use the import library name. - return targetNameImport; - } - else - { - // Use the canonical name. - return targetName; - } - } - else - { - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, - targetNameImport, targetNamePDB, - this->ConfigurationName); - if(this->ImportLibrary) - { - // Use the import library name. - return targetNameImport; - } - else if(useSOName) - { - // Use the soname. - return targetNameSO; - } - else - { - // Use the canonical name. - return targetName; - } - } + return this->GetInstallFilename(target, this->ConfigurationName, + this->ImportLibrary, useSOName); } else { |