summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2014-12-19 19:31:22 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2014-12-22 18:33:00 (GMT)
commitc294a115f2a44b60eb6343324e15933ef8a4593d (patch)
tree4f117d7800f39eaacb7355e433c71b865130c6e9 /Source/cmSystemTools.cxx
parente42da30782785a02f0fabc385d14ac8f561af602 (diff)
downloadCMake-c294a115f2a44b60eb6343324e15933ef8a4593d.zip
CMake-c294a115f2a44b60eb6343324e15933ef8a4593d.tar.gz
CMake-c294a115f2a44b60eb6343324e15933ef8a4593d.tar.bz2
Mach-O: Use Mach-O parser to extract install names instead of otool.
This has much better performance than calling "otool" or "xcrun -r otool" to extract install names for rpath support. Fixes bug #15178.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx34
1 files changed, 12 insertions, 22 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index c83dc2a..1c8c387 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -63,6 +63,10 @@
# include "cmELF.h"
#endif
+#if defined(CMAKE_USE_MACH_PARSER)
+# include "cmMachO.h"
+#endif
+
class cmSystemToolsFileTime
{
public:
@@ -2357,31 +2361,17 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
std::string& soname)
{
- std::vector<std::string> cmds;
- cmds.push_back("otool");
- cmds.push_back("-D");
- cmds.push_back(fullPath);
-
- std::string output;
- if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE))
+#if defined(CMAKE_USE_MACH_PARSER)
+ cmMachO macho(fullPath.c_str());
+ if(macho)
{
- cmds.insert(cmds.begin(), "-r");
- cmds.insert(cmds.begin(), "xcrun");
- if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE))
- {
- return false;
- }
+ return macho.GetInstallName(soname);
}
+#else
+ (void)fullPath;
+ (void)soname;
+#endif
- std::vector<std::string> strs = cmSystemTools::tokenize(output, "\n");
- // otool returns extra lines reporting multiple install names
- // in case the binary is multi-arch and none of the architectures
- // is native (e.g. i386;ppc on x86_64)
- if(strs.size() >= 2)
- {
- soname = strs[1];
- return true;
- }
return false;
}