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.
This commit is contained in:
parent
e42da30782
commit
c294a115f2
|
@ -63,6 +63,10 @@
|
||||||
# include "cmELF.h"
|
# include "cmELF.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CMAKE_USE_MACH_PARSER)
|
||||||
|
# include "cmMachO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class cmSystemToolsFileTime
|
class cmSystemToolsFileTime
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -2357,31 +2361,17 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
|
||||||
bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
|
bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
|
||||||
std::string& soname)
|
std::string& soname)
|
||||||
{
|
{
|
||||||
std::vector<std::string> cmds;
|
#if defined(CMAKE_USE_MACH_PARSER)
|
||||||
cmds.push_back("otool");
|
cmMachO macho(fullPath.c_str());
|
||||||
cmds.push_back("-D");
|
if(macho)
|
||||||
cmds.push_back(fullPath);
|
|
||||||
|
|
||||||
std::string output;
|
|
||||||
if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE))
|
|
||||||
{
|
{
|
||||||
cmds.insert(cmds.begin(), "-r");
|
return macho.GetInstallName(soname);
|
||||||
cmds.insert(cmds.begin(), "xcrun");
|
|
||||||
if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue