From ca12bbb8457b46c1d14a1b52ac2729f2da57f416 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 28 Jun 2018 18:36:52 +0000 Subject: [PATCH] [CMake] Respect CMAKE_STRIP and CMAKE_DSYMUTIL on apple platforms This allows overriding the strip and dsymutil tools, and updates iOS.cmake to do so. I've also added libtool to iOS.cmake, but it was already respecting CMAKE_LIBTOOL if set. llvm-svn: 335900 --- llvm/cmake/modules/AddLLVM.cmake | 10 ++++++++-- llvm/cmake/platforms/iOS.cmake | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 0f3e34306978..62a2cfcf261f 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1557,7 +1557,10 @@ function(llvm_externalize_debuginfo name) if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP) if(APPLE) - set(strip_command COMMAND xcrun strip -Sxl $) + if(NOT CMAKE_STRIP) + set(CMAKE_STRIP xcrun strip) + endif() + set(strip_command COMMAND ${CMAKE_STRIP} -Sxl $) else() set(strip_command COMMAND ${CMAKE_STRIP} -gx $) endif() @@ -1571,8 +1574,11 @@ function(llvm_externalize_debuginfo name) set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-object_path_lto,${lto_object}") endif() + if(NOT CMAKE_DSYMUTIL) + set(CMAKE_DSYMUTIL xcrun dsymutil) + endif() add_custom_command(TARGET ${name} POST_BUILD - COMMAND xcrun dsymutil $ + COMMAND ${CMAKE_DSYMUTIL} $ ${strip_command} ) else() diff --git a/llvm/cmake/platforms/iOS.cmake b/llvm/cmake/platforms/iOS.cmake index 15c7aae12c70..d15db933a6b3 100644 --- a/llvm/cmake/platforms/iOS.cmake +++ b/llvm/cmake/platforms/iOS.cmake @@ -53,3 +53,30 @@ IF(NOT CMAKE_RANLIB) SET(CMAKE_RANLIB ${CMAKE_RANLIB_val} CACHE FILEPATH "Ranlib") message(STATUS "Using ranlib ${CMAKE_RANLIB}") ENDIF() + +IF(NOT CMAKE_STRIP) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find strip + OUTPUT_VARIABLE CMAKE_STRIP_val + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + SET(CMAKE_STRIP ${CMAKE_STRIP_val} CACHE FILEPATH "Strip") + message(STATUS "Using strip ${CMAKE_STRIP}") +ENDIF() + +IF(NOT CMAKE_DSYMUTIL) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find dsymutil + OUTPUT_VARIABLE CMAKE_DSYMUTIL_val + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + SET(CMAKE_DSYMUTIL ${CMAKE_DSYMUTIL_val} CACHE FILEPATH "Dsymutil") + message(STATUS "Using dsymutil ${CMAKE_DSYMUTIL}") +ENDIF() + +IF(NOT CMAKE_LIBTOOL) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool + OUTPUT_VARIABLE CMAKE_LIBTOOL_val + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + SET(CMAKE_LIBTOOL ${CMAKE_LIBTOOL_val} CACHE FILEPATH "Libtool") + message(STATUS "Using libtool ${CMAKE_LIBTOOL}") +ENDIF()