[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
This commit is contained in:
Justin Bogner 2018-06-28 18:36:52 +00:00
parent 21e7aab7e5
commit ca12bbb845
2 changed files with 35 additions and 2 deletions

View File

@ -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 $<TARGET_FILE:${name}>)
if(NOT CMAKE_STRIP)
set(CMAKE_STRIP xcrun strip)
endif()
set(strip_command COMMAND ${CMAKE_STRIP} -Sxl $<TARGET_FILE:${name}>)
else()
set(strip_command COMMAND ${CMAKE_STRIP} -gx $<TARGET_FILE:${name}>)
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 $<TARGET_FILE:${name}>
COMMAND ${CMAKE_DSYMUTIL} $<TARGET_FILE:${name}>
${strip_command}
)
else()

View File

@ -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()