diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2014-02-02 04:18:04 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2014-02-03 14:04:54 (GMT) |
commit | 028a5285d8ff5053fc96ea9840cb341bdf636e24 (patch) | |
tree | bdf44e70945eb207b0f61f38ace628029fed8f5b /Source/cmGlobalXCodeGenerator.cxx | |
parent | 6385c7151631a4ac72490540fe75cb0b9ebbedf5 (diff) | |
download | CMake-028a5285d8ff5053fc96ea9840cb341bdf636e24.zip CMake-028a5285d8ff5053fc96ea9840cb341bdf636e24.tar.gz CMake-028a5285d8ff5053fc96ea9840cb341bdf636e24.tar.bz2 |
OS X: Make sure RPATHs are unique to avoid possible corruption.
When using link_directories() and including CMAKE_CFG_INTDIR,
one can end up with duplicate RPATHs in the binary which
install_name_tool cannot fix without corrupting the binary.
Also, the cmake_install.cmake file has been fixed to correctly
handle these generator specific variables.
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 46c34d0..484b28f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2272,14 +2272,24 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string search_paths; std::vector<std::string> runtimeDirs; pcli->GetRPath(runtimeDirs, false); + // runpath dirs needs to be unique to prevent corruption + std::set<std::string> unique_dirs; + for(std::vector<std::string>::const_iterator i = runtimeDirs.begin(); i != runtimeDirs.end(); ++i) { - if(!search_paths.empty()) + std::string runpath = *i; + runpath = this->ExpandCFGIntDir(runpath, configName); + + if(unique_dirs.find(runpath) == unique_dirs.end()) { - search_paths += " "; + unique_dirs.insert(runpath); + if(!search_paths.empty()) + { + search_paths += " "; + } + search_paths += this->XCodeEscapePath(runpath.c_str()); } - search_paths += this->XCodeEscapePath((*i).c_str()); } if(!search_paths.empty()) { @@ -3675,6 +3685,30 @@ const char* cmGlobalXCodeGenerator::GetCMakeCFGIntDir() const "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" : "."; } +std::string cmGlobalXCodeGenerator::ExpandCFGIntDir(const std::string& str, + const std::string& config) const +{ + std::string replace1 = "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; + std::string replace2 = "$(CONFIGURATION)"; + + std::string tmp = str; + for(std::string::size_type i = tmp.find(replace1); + i != std::string::npos; + i = tmp.find(replace1, i)) + { + tmp.replace(i, replace1.size(), config); + i += config.size(); + } + for(std::string::size_type i = tmp.find(replace2); + i != std::string::npos; + i = tmp.find(replace2, i)) + { + tmp.replace(i, replace2.size(), config); + i += config.size(); + } + return tmp; +} + //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry) { |