summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2014-02-02 04:18:04 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2014-02-03 14:04:54 (GMT)
commit028a5285d8ff5053fc96ea9840cb341bdf636e24 (patch)
treebdf44e70945eb207b0f61f38ace628029fed8f5b /Source/cmGlobalXCodeGenerator.cxx
parent6385c7151631a4ac72490540fe75cb0b9ebbedf5 (diff)
downloadCMake-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.cxx40
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)
{