llvm.org GIT mirror llvm / dbd3af2
[llvm] Add stripped installation targets CMake's generated installation scripts support `CMAKE_INSTALL_DO_STRIP` to enable stripping the installed binaries. LLVM's build system doesn't expose this option to the `install-` targets, but it's useful in conjunction with `install-distribution`. Add a new function to create the install targets, which creates both the regular install target and a second install target that strips during installation. Change the creation of all installation targets to use this new function. Stripping doesn't make a whole lot of sense for some installation targets (e.g. the LLVM headers), but consistency doesn't hurt. I'll make other repositories (e.g. clang, compiler-rt) use this in a follow-up, and then add an `install-distribution-stripped` target to actually accomplish the end goal of creating a stripped distribution. I don't want to do that step yet because the creation of that target would depend on the presence of the `install-*-stripped` target for each distribution component, and the distribution components from other repositories will be missing that target right now. Differential Revision: https://reviews.llvm.org/D40620 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319480 91177308-0d34-0410-b5e6-96231b3b80d8 Shoaib Meenai 1 year, 8 months ago
5 changed file(s) with 57 addition(s) and 54 deletion(s). Raw diff Collapse all Expand all
974974 set_target_properties(llvm-headers PROPERTIES FOLDER "Misc")
975975
976976 if (NOT CMAKE_CONFIGURATION_TYPES)
977 add_custom_target(install-llvm-headers
978 DEPENDS llvm-headers
979 COMMAND "${CMAKE_COMMAND}"
980 -DCMAKE_INSTALL_COMPONENT=llvm-headers
981 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
977 add_llvm_install_targets(install-llvm-headers
978 COMPONENT llvm-headers)
982979 endif()
983980 endif()
984981
568568 endif()
569569 endfunction()
570570
571 function(add_llvm_install_targets target)
572 cmake_parse_arguments(ARG "" "COMPONENT;PREFIX" "DEPENDS" ${ARGN})
573 if(ARG_COMPONENT)
574 set(component_option -DCMAKE_INSTALL_COMPONENT="${ARG_COMPONENT}")
575 endif()
576 if(ARG_PREFIX)
577 set(prefix_option -DCMAKE_INSTALL_PREFIX="${ARG_PREFIX}")
578 endif()
579
580 add_custom_target(${target}
581 DEPENDS ${ARG_DEPENDS}
582 COMMAND "${CMAKE_COMMAND}"
583 ${component_option}
584 ${prefix_option}
585 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
586 USES_TERMINAL)
587 add_custom_target(${target}-stripped
588 DEPENDS ${ARG_DEPENDS}
589 COMMAND "${CMAKE_COMMAND}"
590 ${component_option}
591 ${prefix_option}
592 -DCMAKE_INSTALL_DO_STRIP=1
593 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
594 USES_TERMINAL)
595 endfunction()
596
571597 macro(add_llvm_library name)
572598 cmake_parse_arguments(ARG
573599 "SHARED;BUILDTREE_ONLY"
618644 COMPONENT ${name})
619645
620646 if (NOT CMAKE_CONFIGURATION_TYPES)
621 add_custom_target(install-${name}
622 DEPENDS ${name}
623 COMMAND "${CMAKE_COMMAND}"
624 -DCMAKE_INSTALL_COMPONENT=${name}
625 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
647 add_llvm_install_targets(install-${name}
648 DEPENDS ${name}
649 COMPONENT ${name})
626650 endif()
627651 endif()
628652 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
848872 COMPONENT ${name})
849873
850874 if (NOT CMAKE_CONFIGURATION_TYPES)
851 add_custom_target(install-${name}
852 DEPENDS ${name}
853 COMMAND "${CMAKE_COMMAND}"
854 -DCMAKE_INSTALL_COMPONENT=${name}
855 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
875 add_llvm_install_targets(install-${name}
876 DEPENDS ${name}
877 COMPONENT ${name})
856878 endif()
857879 endif()
858880 endif()
888910 RUNTIME DESTINATION ${LLVM_UTILS_INSTALL_DIR}
889911 COMPONENT ${name})
890912 if (NOT CMAKE_CONFIGURATION_TYPES)
891 add_custom_target(install-${name}
892 DEPENDS ${name}
893 COMMAND "${CMAKE_COMMAND}"
894 -DCMAKE_INSTALL_COMPONENT=${name}
895 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
913 add_llvm_install_targets(install-${name}
914 DEPENDS ${name}
915 COMPONENT ${name})
896916 endif()
897917 endif()
898918 endmacro(add_llvm_utility name)
13991419 COMPONENT ${component})
14001420
14011421 if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
1402 add_custom_target(install-${name}
1403 DEPENDS ${name} ${dest} install-${dest}
1404 COMMAND "${CMAKE_COMMAND}"
1405 -DCMAKE_INSTALL_COMPONENT=${name}
1406 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
1422 add_llvm_install_targets(install-${name}
1423 DEPENDS ${name} ${dest} install-${dest}
1424 COMPONENT ${name})
14071425 endif()
14081426 endfunction()
14091427
14341452 COMPONENT ${component})
14351453
14361454 if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
1437 add_custom_target(install-${name}
1438 DEPENDS ${name} ${dest} install-${dest}
1439 COMMAND "${CMAKE_COMMAND}"
1440 -DCMAKE_INSTALL_COMPONENT=${name}
1441 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
1455 add_llvm_install_targets(install-${name}
1456 DEPENDS ${name} ${dest} install-${dest}
1457 COMPONENT ${name})
14421458 endif()
14431459 endfunction()
14441460
128128 if (NOT CMAKE_CONFIGURATION_TYPES)
129129 # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
130130 add_custom_target(cmake-exports)
131 add_custom_target(install-cmake-exports
132 COMMAND "${CMAKE_COMMAND}"
133 -DCMAKE_INSTALL_COMPONENT=cmake-exports
134 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
131 add_llvm_install_targets(install-cmake-exports
132 COMPONENT cmake-exports)
135133 endif()
136134 endif()
188188 install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${BINARY_DIR}/cmake_install.cmake \)"
189189 COMPONENT ${name})
190190
191 add_custom_target(install-${name}
192 DEPENDS ${name}
193 COMMAND "${CMAKE_COMMAND}"
194 -DCMAKE_INSTALL_COMPONENT=${name}
195 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
196 USES_TERMINAL)
191 add_llvm_install_targets(install-${name}
192 DEPENDS ${name}
193 COMPONENT ${name})
197194 endif()
198195
199196 # Add top-level targets
9292 COMMAND /usr/libexec/PlistBuddy -c "Add:CompatibilityVersion integer ${COMPAT_VERSION}" "${LLVMToolchainDir}/Info.plist"
9393 )
9494
95 add_custom_target(install-xcode-toolchain
96 DEPENDS ${LLVMToolchainDir}/Info.plist
97 COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target all
98 COMMAND "${CMAKE_COMMAND}"
99 -DCMAKE_INSTALL_PREFIX=${LLVMToolchainDir}/usr/
100 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
101 USES_TERMINAL)
95 add_custom_target(build-xcode-toolchain
96 COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target all)
97 add_llvm_install_targets(install-xcode-toolchain
98 DEPENDS ${LLVMToolchainDir}/Info.plist build-xcode-toolchain
99 PREFIX ${LLVMToolchainDir}/usr/)
102100
103101 if(LLVM_DISTRIBUTION_COMPONENTS)
104102 if(CMAKE_CONFIGURATION_TYPES)
109107 DEPENDS ${LLVMToolchainDir}/Info.plist distribution)
110108
111109 foreach(target ${LLVM_DISTRIBUTION_COMPONENTS})
112 add_custom_target(install-distribution-${target}
113 DEPENDS ${target}
114 COMMAND "${CMAKE_COMMAND}"
115 -DCMAKE_INSTALL_COMPONENT=${target}
116 -DCMAKE_INSTALL_PREFIX=${LLVMToolchainDir}/usr/
117 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
118 USES_TERMINAL)
110 add_llvm_install_targets(install-distribution-${target}
111 DEPENDS ${target}
112 COMPONENT ${target}
113 PREFIX ${LLVMToolchainDir}/usr/)
119114 add_dependencies(install-distribution-toolchain install-distribution-${target})
120115 endforeach()
121116 endif()