[PATCH] D40620: [llvm] Add option to strip binaries during installation

Chris Bieneman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 15:50:50 PST 2017


beanz added a comment.

So, I wasn't actually familiar with how `CMAKE_INSTALL_DO_STRIP` worked, so I went and researched it. I think we actually should mimic how that works. So instead of having an option that enables stripping on the install targets, we should create two targets, one that strips and one that doesn't. Then the user can select whether or not they want their install contents stripped by choosing which target they run.

Also because of how many places we create these install targets we probably should abstract it into a function in AddLLVM.cmake (something like `add_llvm_install_targets`), which would take a target name and optional component and install prefix, and dependencies. That function would look something like:

  function(add_llvm_install_targets target)
    cmake_parse_arguments(ARG "" "COMPONENT;PREFIX" "DEPENDS" ${ARGN})
    if(ARG_COMPONENT)
      set(component_option -DCMAKE_INSTALL_COMPONENT=${ARG_COMPONENT})
    endif()
    if(ARG_PREFIX)
      set(prefix_option -DCMAKE_INSTALL_PREFIX=${ARG_PREFIX})
    endif()
    add_custom_target(${target}
                      DEPENDS ${ARG_DEPENDS}
                      COMMAND "${CMAKE_COMMAND}"
                              ${component_option}
                              ${prefix_option}
                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
                      USES_TERMINAL)
  
    add_custom_target(${target}/strip
                      DEPENDS ${ARG_DEPENDS}
                      COMMAND "${CMAKE_COMMAND}"
                              ${component_option}
                              ${prefix_option}
                              -DCMAKE_INSTALL_DO_STRIP=1
                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
                      USES_TERMINAL)
  endfunction()

Then you just change the places we create install targets to be calls like:

  add_llvm_install_targets(install-${name}
                        DEPENDS ${name}
                        COMPONENT ${name})

or

  add_llvm_install_targets(install-distribution-${target}
                  DEPENDS ${target}
                  COMPONENT ${target}
                  PREFIX ${LLVMToolchainDir}/usr/)


https://reviews.llvm.org/D40620





More information about the llvm-commits mailing list