diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/cmInstallTargetGenerator.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2 |
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.
* If you reached this commit for a line in `git blame`, re-run the blame
operation starting at the parent of this commit to see older history
for the content.
* See the parent commit for instructions to rebase a change across this
style transition commit.
Diffstat (limited to 'Source/cmInstallTargetGenerator.cxx')
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 601 |
1 files changed, 245 insertions, 356 deletions
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7e5817e..e68bac2 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -22,68 +22,57 @@ #include <assert.h> -cmInstallTargetGenerator -::cmInstallTargetGenerator(const std::string& targetName, - const char* dest, bool implib, - const char* file_permissions, - std::vector<std::string> const& configurations, - const char* component, - MessageLevel message, - bool exclude_from_all, - bool optional): - cmInstallGenerator(dest, configurations, component, message, - exclude_from_all), - TargetName(targetName), - Target(0), - FilePermissions(file_permissions), - ImportLibrary(implib), - Optional(optional) +cmInstallTargetGenerator::cmInstallTargetGenerator( + const std::string& targetName, const char* dest, bool implib, + const char* file_permissions, std::vector<std::string> const& configurations, + const char* component, MessageLevel message, bool exclude_from_all, + bool optional) + : cmInstallGenerator(dest, configurations, component, message, + exclude_from_all) + , TargetName(targetName) + , Target(0) + , FilePermissions(file_permissions) + , ImportLibrary(implib) + , Optional(optional) { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; } -cmInstallTargetGenerator -::~cmInstallTargetGenerator() +cmInstallTargetGenerator::~cmInstallTargetGenerator() { } void cmInstallTargetGenerator::GenerateScript(std::ostream& os) { // Warn if installing an exclude-from-all target. - if(this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) - { + if (this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { std::ostringstream msg; msg << "WARNING: Target \"" << this->Target->GetName() << "\" has EXCLUDE_FROM_ALL set and will not be built by default " << "but an install rule has been provided for it. CMake does " << "not define behavior for this case."; cmSystemTools::Message(msg.str().c_str(), "Warning"); - } + } // Perform the main install script generation. this->cmInstallGenerator::GenerateScript(os); } -void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, - const std::string& config, - Indent const& indent) +void cmInstallTargetGenerator::GenerateScriptForConfig( + std::ostream& os, const std::string& config, Indent const& indent) { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->NeedRelinkBeforeInstall(config)) - { + if (this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = - this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); + this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); fromDirConfig += cmake::GetCMakeFilesDirectory(); fromDirConfig += "/CMakeRelink.dir/"; - } - else - { - fromDirConfig = - this->Target->GetDirectory(config, this->ImportLibrary); + } else { + fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); fromDirConfig += "/"; - } + } std::string toDir = this->ConvertToAbsoluteDestination(this->GetDestination(config)); toDir += "/"; @@ -94,12 +83,19 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string literal_args; cmState::TargetType targetType = this->Target->GetType(); cmInstallType type = cmInstallType(); - switch(targetType) - { - case cmState::EXECUTABLE: type = cmInstallType_EXECUTABLE; break; - case cmState::STATIC_LIBRARY: type = cmInstallType_STATIC_LIBRARY; break; - case cmState::SHARED_LIBRARY: type = cmInstallType_SHARED_LIBRARY; break; - case cmState::MODULE_LIBRARY: type = cmInstallType_MODULE_LIBRARY; break; + switch (targetType) { + case cmState::EXECUTABLE: + type = cmInstallType_EXECUTABLE; + break; + case cmState::STATIC_LIBRARY: + type = cmInstallType_STATIC_LIBRARY; + break; + case cmState::SHARED_LIBRARY: + type = cmInstallType_SHARED_LIBRARY; + break; + case cmState::MODULE_LIBRARY: + type = cmInstallType_MODULE_LIBRARY; + break; case cmState::INTERFACE_LIBRARY: // Not reachable. We never create a cmInstallTargetGenerator for // an INTERFACE_LIBRARY. @@ -109,12 +105,12 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, case cmState::UTILITY: case cmState::GLOBAL_TARGET: case cmState::UNKNOWN_LIBRARY: - this->Target->GetLocalGenerator()->IssueMessage(cmake::INTERNAL_ERROR, + this->Target->GetLocalGenerator()->IssueMessage( + cmake::INTERNAL_ERROR, "cmInstallTargetGenerator created with non-installable target."); return; - } - if(targetType == cmState::EXECUTABLE) - { + } + if (targetType == cmState::EXECUTABLE) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -123,33 +119,27 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameImport; std::string targetNamePDB; this->Target->GetExecutableNames(targetName, targetNameReal, - targetNameImport, targetNamePDB, - config); - if(this->ImportLibrary) - { + targetNameImport, targetNamePDB, config); + if (this->ImportLibrary) { std::string from1 = fromDirConfig + targetNameImport; std::string to1 = toDir + targetNameImport; filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->GetImplibGNUtoMS(targetNameImport, - targetNameImportLib)) - { + if (this->Target->GetImplibGNUtoMS(targetNameImport, + targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); filesTo.push_back(toDir + targetNameImportLib); - } + } // An import library looks like a static library. type = cmInstallType_STATIC_LIBRARY; - } - else - { + } else { std::string from1 = fromDirConfig + targetName; std::string to1 = toDir + targetName; // Handle OSX Bundles. - if(this->Target->IsAppBundleOnApple()) - { + if (this->Target->IsAppBundleOnApple()) { cmMakefile const* mf = this->Target->Target->GetMakefile(); // Install the whole app bundle directory. @@ -159,41 +149,32 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, // Tweaks apply to the binary inside the bundle. to1 += ".app/"; - if(!mf->PlatformIsAppleIos()) - { + if (!mf->PlatformIsAppleIos()) { to1 += "Contents/MacOS/"; - } - to1 += targetName; } - else - { + to1 += targetName; + } else { // Tweaks apply to the real file, so list it first. - if(targetNameReal != targetName) - { + if (targetNameReal != targetName) { std::string from2 = fromDirConfig + targetNameReal; std::string to2 = toDir += targetNameReal; filesFrom.push_back(from2); filesTo.push_back(to2); - } } + } filesFrom.push_back(from1); filesTo.push_back(to1); - } } - else - { + } 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); - if(this->ImportLibrary) - { + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + targetNameImport, targetNamePDB, config); + if (this->ImportLibrary) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -202,18 +183,15 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->GetImplibGNUtoMS(targetNameImport, - targetNameImportLib)) - { + if (this->Target->GetImplibGNUtoMS(targetNameImport, + targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); filesTo.push_back(toDir + targetNameImportLib); - } + } // An import library looks like a static library. type = cmInstallType_STATIC_LIBRARY; - } - else if(this->Target->IsFrameworkOnApple()) - { + } else if (this->Target->IsFrameworkOnApple()) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -229,9 +207,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); - } - else if(this->Target->IsCFBundleOnApple()) - { + } else if (this->Target->IsCFBundleOnApple()) { // Install the whole app bundle directory. type = cmInstallType_DIRECTORY; literal_args += " USE_SOURCE_PERMISSIONS"; @@ -243,9 +219,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); - } - else - { + } else { bool haveNamelink = false; // Library link name. @@ -255,79 +229,65 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, // Library interface name. std::string fromSOName; std::string toSOName; - if(targetNameSO != targetName) - { + if (targetNameSO != targetName) { haveNamelink = true; fromSOName = fromDirConfig + targetNameSO; toSOName = toDir + targetNameSO; - } + } // Library implementation name. std::string fromRealName; std::string toRealName; - if(targetNameReal != targetName && - targetNameReal != targetNameSO) - { + if (targetNameReal != targetName && targetNameReal != targetNameSO) { haveNamelink = true; fromRealName = fromDirConfig + targetNameReal; toRealName = toDir + targetNameReal; - } + } // Add the names based on the current namelink mode. - if(haveNamelink) - { + if (haveNamelink) { // With a namelink we need to check the mode. - if(this->NamelinkMode == NamelinkModeOnly) - { + if (this->NamelinkMode == NamelinkModeOnly) { // Install the namelink only. filesFrom.push_back(fromName); filesTo.push_back(toName); - } - else - { + } else { // Install the real file if it has its own name. - if(!fromRealName.empty()) - { + if (!fromRealName.empty()) { filesFrom.push_back(fromRealName); filesTo.push_back(toRealName); - } + } // Install the soname link if it has its own name. - if(!fromSOName.empty()) - { + if (!fromSOName.empty()) { filesFrom.push_back(fromSOName); filesTo.push_back(toSOName); - } + } // Install the namelink if it is not to be skipped. - if(this->NamelinkMode != NamelinkModeSkip) - { + if (this->NamelinkMode != NamelinkModeSkip) { filesFrom.push_back(fromName); filesTo.push_back(toName); - } } } - else - { + } else { // Without a namelink there will be only one file. Install it // if this is not a namelink-only rule. - if(this->NamelinkMode != NamelinkModeOnly) - { + if (this->NamelinkMode != NamelinkModeOnly) { filesFrom.push_back(fromName); filesTo.push_back(toName); - } } } } + } // If this fails the above code is buggy. assert(filesFrom.size() == filesTo.size()); // Skip this rule if no files are to be installed for the target. - if(filesFrom.empty()) - { + if (filesFrom.empty()) { return; - } + } // Add pre-installation tweaks. this->AddTweak(os, indent, config, filesTo, @@ -337,10 +297,9 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, const char* no_dir_permissions = 0; const char* no_rename = 0; bool optional = this->Optional || this->ImportLibrary; - this->AddInstallRule(os, this->GetDestination(config), - type, filesFrom, optional, - this->FilePermissions.c_str(), no_dir_permissions, - no_rename, literal_args.c_str(), + this->AddInstallRule(os, this->GetDestination(config), type, filesFrom, + optional, this->FilePermissions.c_str(), + no_dir_permissions, no_rename, literal_args.c_str(), indent); // Add post-installation tweaks. @@ -348,61 +307,49 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, &cmInstallTargetGenerator::PostReplacementTweaks); } -std::string -cmInstallTargetGenerator::GetDestination(std::string const& config) const +std::string cmInstallTargetGenerator::GetDestination( + std::string const& config) const { cmGeneratorExpression ge; return ge.Parse(this->Destination) ->Evaluate(this->Target->GetLocalGenerator(), config); } -std::string -cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const +std::string cmInstallTargetGenerator::GetInstallFilename( + const std::string& config) const { - NameType nameType = this->ImportLibrary? NameImplib : NameNormal; - return - cmInstallTargetGenerator::GetInstallFilename(this->Target, config, - nameType); + NameType nameType = this->ImportLibrary ? NameImplib : NameNormal; + return cmInstallTargetGenerator::GetInstallFilename(this->Target, config, + nameType); } -std::string -cmInstallTargetGenerator::GetInstallFilename(cmGeneratorTarget const* target, - const std::string& config, - NameType nameType) +std::string cmInstallTargetGenerator::GetInstallFilename( + cmGeneratorTarget const* target, const std::string& config, + NameType nameType) { std::string fname; // Compute the name of the library. - if(target->GetType() == cmState::EXECUTABLE) - { + if (target->GetType() == cmState::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, - targetNameImport, targetNamePDB, - config); - if(nameType == NameImplib) - { + target->GetExecutableNames(targetName, targetNameReal, targetNameImport, + targetNamePDB, config); + if (nameType == NameImplib) { // Use the import library name. - if(!target->GetImplibGNUtoMS(targetNameImport, fname, - "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) - { + if (!target->GetImplibGNUtoMS(targetNameImport, fname, + "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { fname = targetNameImport; - } } - else if(nameType == NameReal) - { + } else if (nameType == NameReal) { // Use the canonical name. fname = targetNameReal; - } - else - { + } else { // Use the canonical name. fname = targetName; - } } - else - { + } else { std::string targetName; std::string targetNameSO; std::string targetNameReal; @@ -410,31 +357,23 @@ cmInstallTargetGenerator::GetInstallFilename(cmGeneratorTarget const* target, std::string targetNamePDB; target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); - if(nameType == NameImplib) - { + if (nameType == NameImplib) { // Use the import library name. - if(!target->GetImplibGNUtoMS(targetNameImport, fname, - "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) - { + if (!target->GetImplibGNUtoMS(targetNameImport, fname, + "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { fname = targetNameImport; - } } - else if(nameType == NameSO) - { + } else if (nameType == NameSO) { // Use the soname. fname = targetNameSO; - } - else if(nameType == NameReal) - { + } else if (nameType == NameReal) { // Use the real name. fname = targetNameReal; - } - else - { + } else { // Use the canonical name. fname = targetName; - } } + } return fname; } @@ -444,53 +383,47 @@ void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg) this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName); } -void -cmInstallTargetGenerator -::AddTweak(std::ostream& os, Indent const& indent, const std::string& config, - std::string const& file, TweakMethod tweak) +void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent const& indent, + const std::string& config, + std::string const& file, + TweakMethod tweak) { std::ostringstream tw; (this->*tweak)(tw, indent.Next(), config, file); std::string tws = tw.str(); - if(!tws.empty()) - { + if (!tws.empty()) { os << indent << "if(EXISTS \"" << file << "\" AND\n" << indent << " NOT IS_SYMLINK \"" << file << "\")\n"; os << tws; os << indent << "endif()\n"; - } + } } -void -cmInstallTargetGenerator -::AddTweak(std::ostream& os, Indent const& indent, const std::string& config, - std::vector<std::string> const& files, TweakMethod tweak) +void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent const& indent, + const std::string& config, + std::vector<std::string> const& files, + TweakMethod tweak) { - if(files.size() == 1) - { + if (files.size() == 1) { // Tweak a single file. this->AddTweak(os, indent, config, this->GetDestDirPath(files[0]), tweak); - } - else - { + } else { // Generate a foreach loop to tweak multiple files. std::ostringstream tw; this->AddTweak(tw, indent.Next(), config, "${file}", tweak); std::string tws = tw.str(); - if(!tws.empty()) - { + if (!tws.empty()) { Indent indent2 = indent.Next().Next(); os << indent << "foreach(file\n"; - for(std::vector<std::string>::const_iterator i = files.begin(); - i != files.end(); ++i) - { + for (std::vector<std::string>::const_iterator i = files.begin(); + i != files.end(); ++i) { os << indent2 << "\"" << this->GetDestDirPath(*i) << "\"\n"; - } + } os << indent2 << ")\n"; os << tws; os << indent << "endforeach()\n"; - } } + } } std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file) @@ -498,10 +431,9 @@ std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file) // Construct the path of the file on disk after installation on // which tweaks may be performed. std::string toDestDirPath = "$ENV{DESTDIR}"; - if(file[0] != '/' && file[0] != '$') - { + if (file[0] != '/' && file[0] != '$') { toDestDirPath += "/"; - } + } toDestDirPath += file; return toDestDirPath; } @@ -515,9 +447,9 @@ void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os, } void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, - Indent const& indent, - const std::string& config, - std::string const& file) + Indent const& indent, + const std::string& config, + std::string const& file) { this->AddInstallNamePatchRule(os, indent, config, file); this->AddChrpathPatchRule(os, indent, config, file); @@ -526,58 +458,52 @@ void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, this->AddStripRule(os, indent, file); } -void -cmInstallTargetGenerator -::AddInstallNamePatchRule(std::ostream& os, Indent const& indent, - const std::string& config, - std::string const& toDestDirPath) +void cmInstallTargetGenerator::AddInstallNamePatchRule( + std::ostream& os, Indent const& indent, const std::string& config, + std::string const& toDestDirPath) { - if(this->ImportLibrary || - !(this->Target->GetType() == cmState::SHARED_LIBRARY || - this->Target->GetType() == cmState::MODULE_LIBRARY || - this->Target->GetType() == cmState::EXECUTABLE)) - { + if (this->ImportLibrary || + !(this->Target->GetType() == cmState::SHARED_LIBRARY || + this->Target->GetType() == cmState::MODULE_LIBRARY || + this->Target->GetType() == cmState::EXECUTABLE)) { return; - } + } // Fix the install_name settings in installed binaries. - std::string installNameTool = this->Target->Target->GetMakefile() - ->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL"); + std::string installNameTool = + this->Target->Target->GetMakefile()->GetSafeDefinition( + "CMAKE_INSTALL_NAME_TOOL"); - if(installNameTool.empty()) - { + if (installNameTool.empty()) { return; - } + } // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map<std::string, std::string> install_name_remap; - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) - { - std::set<cmGeneratorTarget const*> const& sharedLibs - = cli->GetSharedLibrariesLinked(); - for(std::set<cmGeneratorTarget const*>::const_iterator j - = sharedLibs.begin(); j != sharedLibs.end(); ++j) - { + if (cmComputeLinkInformation* cli = + this->Target->GetLinkInformation(config)) { + std::set<cmGeneratorTarget const*> const& sharedLibs = + cli->GetSharedLibrariesLinked(); + for (std::set<cmGeneratorTarget const*>::const_iterator j = + sharedLibs.begin(); + j != sharedLibs.end(); ++j) { cmGeneratorTarget const* tgt = *j; // The install_name of an imported target does not change. - if(tgt->IsImported()) - { + if (tgt->IsImported()) { continue; - } + } // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. std::string for_build = tgt->GetInstallNameDirForBuildTree(config); std::string for_install = tgt->GetInstallNameDirForInstallTree(); - if(for_build != for_install) - { + if (for_build != for_install) { // The directory portions differ. Append the filename to // create the mapping. - std::string fname = - this->GetInstallFilename(tgt, config, NameSO); + std::string fname = this->GetInstallFilename(tgt, config, NameSO); // Map from the build-tree install_name. for_build += fname; @@ -587,83 +513,72 @@ cmInstallTargetGenerator // Store the mapping entry. install_name_remap[for_build] = for_install; - } } } + } // Edit the install_name of the target itself if necessary. std::string new_id; - if(this->Target->GetType() == cmState::SHARED_LIBRARY) - { + if (this->Target->GetType() == cmState::SHARED_LIBRARY) { std::string for_build = this->Target->GetInstallNameDirForBuildTree(config); - std::string for_install = - this->Target->GetInstallNameDirForInstallTree(); + std::string for_install = this->Target->GetInstallNameDirForInstallTree(); - if(this->Target->IsFrameworkOnApple() && for_install.empty()) - { + if (this->Target->IsFrameworkOnApple() && for_install.empty()) { // Frameworks seem to have an id corresponding to their own full // path. // ... // for_install = fullDestPath_without_DESTDIR_or_name; - } + } // If the install name will change on installation set the new id // on the installed file. - if(for_build != for_install) - { + if (for_build != for_install) { // Prepare to refer to the install-tree install_name. new_id = for_install; new_id += this->GetInstallFilename(this->Target, config, NameSO); - } } + } // Write a rule to run install_name_tool to set the install-tree // install_name value and references. - if(!new_id.empty() || !install_name_remap.empty()) - { + if (!new_id.empty() || !install_name_remap.empty()) { os << indent << "execute_process(COMMAND \"" << installNameTool; os << "\""; - if(!new_id.empty()) - { + if (!new_id.empty()) { os << "\n" << indent << " -id \"" << new_id << "\""; - } - for(std::map<std::string, std::string>::const_iterator - i = install_name_remap.begin(); - i != install_name_remap.end(); ++i) - { - os << "\n" << indent << " -change \"" - << i->first << "\" \"" << i->second << "\""; - } - os << "\n" << indent << " \"" << toDestDirPath << "\")\n"; } + for (std::map<std::string, std::string>::const_iterator i = + install_name_remap.begin(); + i != install_name_remap.end(); ++i) { + os << "\n" + << indent << " -change \"" << i->first << "\" \"" << i->second + << "\""; + } + os << "\n" << indent << " \"" << toDestDirPath << "\")\n"; + } } -void -cmInstallTargetGenerator -::AddRPathCheckRule(std::ostream& os, Indent const& indent, - const std::string& config, - std::string const& toDestDirPath) +void cmInstallTargetGenerator::AddRPathCheckRule( + std::ostream& os, Indent const& indent, const std::string& config, + std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) - { + if (this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; - } + } // Skip if on Apple - if(this->Target->Target->GetMakefile() - ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { + if (this->Target->Target->GetMakefile()->IsOn( + "CMAKE_PLATFORM_HAS_INSTALLNAME")) { return; - } + } // Get the link information for this target. // It can provide the RPATH. cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); - if(!cli) - { + if (!cli) { return; - } + } // Get the install RPATH from the link information. std::string newRpath = cli->GetChrpathString(); @@ -678,30 +593,25 @@ cmInstallTargetGenerator /* clang-format on */ } -void -cmInstallTargetGenerator -::AddChrpathPatchRule(std::ostream& os, Indent const& indent, - const std::string& config, - std::string const& toDestDirPath) +void cmInstallTargetGenerator::AddChrpathPatchRule( + std::ostream& os, Indent const& indent, const std::string& config, + std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) - { + if (this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; - } + } // Get the link information for this target. // It can provide the RPATH. cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); - if(!cli) - { + if (!cli) { return; - } + } cmMakefile* mf = this->Target->Target->GetMakefile(); - if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { + if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { // If using install_name_tool, set up the rules to modify the rpaths. std::string installNameTool = mf->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL"); @@ -716,57 +626,50 @@ cmInstallTargetGenerator std::stringstream ss(darwin_major_version_s); int darwin_major_version; ss >> darwin_major_version; - if(!ss.fail() && darwin_major_version <= 9 && - (!oldRuntimeDirs.empty() || !newRuntimeDirs.empty()) - ) - { + if (!ss.fail() && darwin_major_version <= 9 && + (!oldRuntimeDirs.empty() || !newRuntimeDirs.empty())) { std::ostringstream msg; - msg << "WARNING: Target \"" << this->Target->GetName() + msg + << "WARNING: Target \"" << this->Target->GetName() << "\" has runtime paths which cannot be changed during install. " << "To change runtime paths, OS X version 10.6 or newer is required. " << "Therefore, runtime paths will not be changed when installing. " << "CMAKE_BUILD_WITH_INSTALL_RPATH may be used to work around" " this limitation."; mf->IssueMessage(cmake::WARNING, msg.str()); - } - else - { + } else { // Note: These paths are kept unique to avoid // install_name_tool corruption. std::set<std::string> runpaths; - for(std::vector<std::string>::const_iterator i = oldRuntimeDirs.begin(); - i != oldRuntimeDirs.end(); ++i) - { + for (std::vector<std::string>::const_iterator i = oldRuntimeDirs.begin(); + i != oldRuntimeDirs.end(); ++i) { std::string runpath = mf->GetGlobalGenerator()->ExpandCFGIntDir(*i, config); - if(runpaths.find(runpath) == runpaths.end()) - { + if (runpaths.find(runpath) == runpaths.end()) { runpaths.insert(runpath); - os << indent << "execute_process(COMMAND " << installNameTool <<"\n"; + os << indent << "execute_process(COMMAND " << installNameTool + << "\n"; os << indent << " -delete_rpath \"" << runpath << "\"\n"; os << indent << " \"" << toDestDirPath << "\")\n"; - } } + } runpaths.clear(); - for(std::vector<std::string>::const_iterator i = newRuntimeDirs.begin(); - i != newRuntimeDirs.end(); ++i) - { + for (std::vector<std::string>::const_iterator i = newRuntimeDirs.begin(); + i != newRuntimeDirs.end(); ++i) { std::string runpath = mf->GetGlobalGenerator()->ExpandCFGIntDir(*i, config); - if(runpaths.find(runpath) == runpaths.end()) - { - os << indent << "execute_process(COMMAND " << installNameTool <<"\n"; + if (runpaths.find(runpath) == runpaths.end()) { + os << indent << "execute_process(COMMAND " << installNameTool + << "\n"; os << indent << " -add_rpath \"" << runpath << "\"\n"; os << indent << " \"" << toDestDirPath << "\")\n"; - } } } } - else - { + } else { // Construct the original rpath string to be replaced. std::string oldRpath = cli->GetRPathString(false); @@ -774,43 +677,39 @@ cmInstallTargetGenerator std::string newRpath = cli->GetChrpathString(); // Skip the rule if the paths are identical - if(oldRpath == newRpath) - { + if (oldRpath == newRpath) { return; - } + } // Write a rule to run chrpath to set the install-tree RPATH os << indent << "file(RPATH_CHANGE\n" << indent << " FILE \"" << toDestDirPath << "\"\n" << indent << " OLD_RPATH \"" << oldRpath << "\"\n" << indent << " NEW_RPATH \"" << newRpath << "\")\n"; - } + } } -void -cmInstallTargetGenerator::AddStripRule(std::ostream& os, - Indent const& indent, - const std::string& toDestDirPath) +void cmInstallTargetGenerator::AddStripRule(std::ostream& os, + Indent const& indent, + const std::string& toDestDirPath) { // don't strip static and import libraries, because it removes the only // symbol table they have so you can't link to them anymore - if(this->Target->GetType()==cmState::STATIC_LIBRARY || this->ImportLibrary) - { + if (this->Target->GetType() == cmState::STATIC_LIBRARY || + this->ImportLibrary) { return; - } + } // Don't handle OSX Bundles. - if(this->Target->Target->GetMakefile()->IsOn("APPLE") && - this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) - { + if (this->Target->Target->GetMakefile()->IsOn("APPLE") && + this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) { return; - } + } - if(! this->Target->Target->GetMakefile()->IsSet("CMAKE_STRIP")) - { + if (!this->Target->Target->GetMakefile()->IsSet("CMAKE_STRIP")) { return; - } + } os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n"; os << indent << " execute_process(COMMAND \"" @@ -819,56 +718,47 @@ cmInstallTargetGenerator::AddStripRule(std::ostream& os, os << indent << "endif()\n"; } -void -cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, - Indent const& indent, - const std::string& toDestDirPath) +void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, + Indent const& indent, + const std::string& toDestDirPath) { // Static libraries need ranlib on this platform. - if(this->Target->GetType() != cmState::STATIC_LIBRARY) - { + if (this->Target->GetType() != cmState::STATIC_LIBRARY) { return; - } + } // Perform post-installation processing on the file depending // on its type. - if(!this->Target->Target->GetMakefile()->IsOn("APPLE")) - { + if (!this->Target->Target->GetMakefile()->IsOn("APPLE")) { return; - } + } std::string ranlib = this->Target->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB"); - if(ranlib.empty()) - { + if (ranlib.empty()) { return; - } + } - os << indent << "execute_process(COMMAND \"" - << ranlib << "\" \"" << toDestDirPath << "\")\n"; + os << indent << "execute_process(COMMAND \"" << ranlib << "\" \"" + << toDestDirPath << "\")\n"; } -void -cmInstallTargetGenerator -::AddUniversalInstallRule(std::ostream& os, - Indent const& indent, - const std::string& toDestDirPath) +void cmInstallTargetGenerator::AddUniversalInstallRule( + std::ostream& os, Indent const& indent, const std::string& toDestDirPath) { cmMakefile const* mf = this->Target->Target->GetMakefile(); - if(!mf->PlatformIsAppleIos() || !mf->IsOn("XCODE")) - { + if (!mf->PlatformIsAppleIos() || !mf->IsOn("XCODE")) { return; - } + } const char* xcodeVersion = mf->GetDefinition("XCODE_VERSION"); - if(!xcodeVersion || cmSystemTools::VersionCompareGreater("6", xcodeVersion)) - { + if (!xcodeVersion || + cmSystemTools::VersionCompareGreater("6", xcodeVersion)) { return; - } + } - switch(this->Target->GetType()) - { + switch (this->Target->GetType()) { case cmState::EXECUTABLE: case cmState::STATIC_LIBRARY: case cmState::SHARED_LIBRARY: @@ -877,15 +767,14 @@ cmInstallTargetGenerator default: return; - } + } - if(!this->Target->Target->GetPropertyAsBool("IOS_INSTALL_COMBINED")) - { - return; - } + if (!this->Target->Target->GetPropertyAsBool("IOS_INSTALL_COMBINED")) { + return; + } os << indent << "include(CMakeIOSInstallCombined)\n"; os << indent << "ios_install_combined(" - << "\"" << this->Target->Target->GetName() << "\" " - << "\"" << toDestDirPath << "\")\n"; + << "\"" << this->Target->Target->GetName() << "\" " + << "\"" << toDestDirPath << "\")\n"; } |