summaryrefslogtreecommitdiff
path: root/Source/cmInstallTargetGenerator.cxx
diff options
context:
space:
mode:
authorHarry Mallon <hjmallon@gmail.com>2019-01-30 17:28:11 +0000
committerHarry Mallon <hjmallon@gmail.com>2019-01-30 22:00:16 +0000
commit20291e8e7293fd0ba0f5c66fe57388ee20381ccb (patch)
tree93503a98013da6d97cf18b765c01e0a70b325a28 /Source/cmInstallTargetGenerator.cxx
parent748d024551d8f447046363ad617fc72bdd977fd2 (diff)
downloadcmake-20291e8e7293fd0ba0f5c66fe57388ee20381ccb.tar.gz
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
Diffstat (limited to 'Source/cmInstallTargetGenerator.cxx')
-rw-r--r--Source/cmInstallTargetGenerator.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 10df70badb..2f59de8838 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -765,10 +765,22 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent,
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 << " execute_process(COMMAND \""
<< this->Target->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
- << "\" \"" << toDestDirPath << "\")\n";
+ << "\" " << stripArgs << "\"" << toDestDirPath << "\")\n";
os << indent << "endif()\n";
}