mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 19:43:23 +08:00
install: Fix stripping on macOS
On macOS the `strip` tool requires special arguments depending on the type of binary to be stripped. Fixes: #11367 Fixes: #16499
This commit is contained in:
@@ -765,10 +765,22 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string stripArgs;
|
||||||
|
|
||||||
|
// macOS 'strip' is picky, executables need '-u -r' and dylibs need '-x'.
|
||||||
|
if (this->Target->Target->GetMakefile()->IsOn("APPLE")) {
|
||||||
|
if (this->Target->GetType() == cmStateEnums::SHARED_LIBRARY ||
|
||||||
|
this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) {
|
||||||
|
stripArgs = "-x ";
|
||||||
|
} else if (this->Target->GetType() == cmStateEnums::EXECUTABLE) {
|
||||||
|
stripArgs = "-u -r ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n";
|
os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n";
|
||||||
os << indent << " execute_process(COMMAND \""
|
os << indent << " execute_process(COMMAND \""
|
||||||
<< this->Target->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
|
<< this->Target->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
|
||||||
<< "\" \"" << toDestDirPath << "\")\n";
|
<< "\" " << stripArgs << "\"" << toDestDirPath << "\")\n";
|
||||||
os << indent << "endif()\n";
|
os << indent << "endif()\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user