[CMake] Respect CMAKE_STRIP and CMAKE_DSYMUTIL on apple platforms
authorJustin Bogner <mail@justinbogner.com>
Thu, 28 Jun 2018 18:36:52 +0000 (18:36 +0000)
committerJustin Bogner <mail@justinbogner.com>
Thu, 28 Jun 2018 18:36:52 +0000 (18:36 +0000)
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
llvm/cmake/platforms/iOS.cmake

index 0f3e343..62a2cfc 100644 (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()
index 15c7aae..d15db93 100644 (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()