summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-22 14:13:04 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-22 14:13:04 (GMT)
commit96fd5909d9dd1ffe740230ce652d574cd01c62d5 (patch)
treee83b3ce2d5066660256a69cacb6caa7d2d95c416 /Source/cmGlobalXCodeGenerator.cxx
parent0df9e6904cd2416336a85d6d7972ce84dcbab417 (diff)
downloadCMake-96fd5909d9dd1ffe740230ce652d574cd01c62d5.zip
CMake-96fd5909d9dd1ffe740230ce652d574cd01c62d5.tar.gz
CMake-96fd5909d9dd1ffe740230ce652d574cd01c62d5.tar.bz2
ENH: Implement linking with paths to library files instead of -L and -l separation. See bug #3832
- This is purely an implementation improvement. No interface has changed. - Create cmComputeLinkInformation class - Move and re-implement logic from: cmLocalGenerator::ComputeLinkInformation cmOrderLinkDirectories - Link libraries to targets with their full path (if it is known) - Dirs specified with link_directories command still added with -L - Make link type specific to library names without paths (name libfoo.a without path becomes -Wl,-Bstatic -lfoo) - Make directory ordering specific to a runtime path computation feature (look for conflicting SONAMEs instead of library names) - Implement proper rpath support on HP-UX and AIX.
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx88
1 files changed, 49 insertions, 39 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 89c9377..cc7e7f8 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -22,6 +22,7 @@ PURPOSE. See the above copyright notices for more information.
#include "cmXCode21Object.h"
#include "cmake.h"
#include "cmGeneratedFileStream.h"
+#include "cmComputeLinkInformation.h"
#include "cmSourceFile.h"
//----------------------------------------------------------------------------
@@ -2107,23 +2108,27 @@ void cmGlobalXCodeGenerator
}
// Compute the link library and directory information.
- std::vector<cmStdString> libNames;
- std::vector<cmStdString> libDirs;
- std::vector<cmStdString> fullPathLibs;
- this->CurrentLocalGenerator->ComputeLinkInformation(*cmtarget, configName,
- libNames, libDirs,
- &fullPathLibs);
+ cmComputeLinkInformation cli(cmtarget, configName);
+ if(!cli.Compute())
+ {
+ continue;
+ }
// Add dependencies directly on library files.
- for(std::vector<cmStdString>::iterator j = fullPathLibs.begin();
- j != fullPathLibs.end(); ++j)
+ {
+ std::vector<std::string> const& libDeps = cli.GetDepends();
+ for(std::vector<std::string>::const_iterator j = libDeps.begin();
+ j != libDeps.end(); ++j)
{
target->AddDependLibrary(configName, j->c_str());
}
+ }
- std::string linkDirs;
// add the library search paths
- for(std::vector<cmStdString>::const_iterator libDir = libDirs.begin();
+ {
+ std::vector<std::string> const& libDirs = cli.GetDirectories();
+ std::string linkDirs;
+ for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
libDir != libDirs.end(); ++libDir)
{
if(libDir->size() && *libDir != "/usr/lib")
@@ -2141,45 +2146,50 @@ void cmGlobalXCodeGenerator
}
this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
linkDirs.c_str(), configName);
+ }
+
+ // add the framework search paths
+ {
+ const char* sep = "";
+ std::string fdirs;
+ std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
+ for(std::vector<std::string>::const_iterator fdi = fwDirs.begin();
+ fdi != fwDirs.end(); ++fdi)
+ {
+ fdirs += sep;
+ sep = " ";
+ fdirs += this->XCodeEscapePath(fdi->c_str());
+ }
+ if(!fdirs.empty())
+ {
+ this->AppendBuildSettingAttribute(target, "FRAMEWORK_SEARCH_PATHS",
+ fdirs.c_str(), configName);
+ }
+ }
+
// now add the link libraries
if(cmtarget->GetType() != cmTarget::STATIC_LIBRARY)
{
- std::string fdirs;
- std::set<cmStdString> emitted;
- emitted.insert("/System/Library/Frameworks");
- for(std::vector<cmStdString>::iterator lib = libNames.begin();
- lib != libNames.end(); ++lib)
+ std::string linkLibs;
+ const char* sep = "";
+ typedef cmComputeLinkInformation::ItemVector ItemVector;
+ ItemVector const& libNames = cli.GetItems();
+ for(ItemVector::const_iterator li = libNames.begin();
+ li != libNames.end(); ++li)
{
- std::string& libString = *lib;
- // check to see if this is a -F framework path and extract it if it is
- // -F framework stuff should be in the FRAMEWORK_SEARCH_PATHS and not
- // OTHER_LDFLAGS
- if(libString.size() > 2 && libString[0] == '-'
- && libString[1] == 'F')
+ linkLibs += sep;
+ sep = " ";
+ if(li->IsPath)
{
- std::string path = libString.substr(2);
- // remove escaped spaces from the path
- cmSystemTools::ReplaceString(path, "\\ ", " ");
- if(emitted.insert(path).second)
- {
- if(fdirs.size())
- {
- fdirs += " ";
- }
- fdirs += this->XCodeEscapePath(path.c_str());
- }
+ linkLibs += this->XCodeEscapePath(li->Value.c_str());
}
else
{
- this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS",
- lib->c_str(), configName);
+ linkLibs += li->Value;
}
}
- if(fdirs.size())
- {
- this->AppendBuildSettingAttribute(target, "FRAMEWORK_SEARCH_PATHS",
- fdirs.c_str(), configName);
- }
+ this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS",
+ linkLibs.c_str(), configName);
}
}
}