[compiler-rt] r360181 - [compiler-rt] Create install targets for Darwin libraries

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 12:00:37 PDT 2019


Author: smeenai
Date: Tue May  7 12:00:37 2019
New Revision: 360181

URL: http://llvm.org/viewvc/llvm-project?rev=360181&view=rev
Log:
[compiler-rt] Create install targets for Darwin libraries

Darwin targets were generating CMake install rules but not the
corresponding install targets. Centralize the existing install target
creation to a function and use that function for both Darwin and
non-Darwin builds.

Differential Revision: https://reviews.llvm.org/D61541

Modified:
    compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
    compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake
    compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake

Modified: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake?rev=360181&r1=360180&r2=360181&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake Tue May  7 12:00:37 2019
@@ -240,28 +240,6 @@ function(add_compiler_rt_runtime name ty
       set_target_properties(${LIB_PARENT_TARGET} PROPERTIES
                             FOLDER "Compiler-RT Misc")
     endif()
-    if(NOT TARGET install-${LIB_PARENT_TARGET})
-      # The parent install target specifies the parent component to scrape up
-      # anything not installed by the individual install targets, and to handle
-      # installation when running the multi-configuration generators.
-      add_custom_target(install-${LIB_PARENT_TARGET}
-                        DEPENDS ${LIB_PARENT_TARGET}
-                        COMMAND "${CMAKE_COMMAND}"
-                                -DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
-                                -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-      add_custom_target(install-${LIB_PARENT_TARGET}-stripped
-                        DEPENDS ${LIB_PARENT_TARGET}
-                        COMMAND "${CMAKE_COMMAND}"
-                                -DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
-                                -DCMAKE_INSTALL_DO_STRIP=1
-                                -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-      set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
-                            FOLDER "Compiler-RT Misc")
-      set_target_properties(install-${LIB_PARENT_TARGET}-stripped PROPERTIES
-                            FOLDER "Compiler-RT Misc")
-      add_dependencies(install-compiler-rt install-${LIB_PARENT_TARGET})
-      add_dependencies(install-compiler-rt-stripped install-${LIB_PARENT_TARGET}-stripped)
-    endif()
   endif()
 
   foreach(libname ${libnames})
@@ -352,27 +330,12 @@ function(add_compiler_rt_runtime name ty
       endif()
     endif()
 
-    # We only want to generate per-library install targets if you aren't using
-    # an IDE because the extra targets get cluttered in IDEs.
-    if(NOT CMAKE_CONFIGURATION_TYPES)
-      add_custom_target(install-${libname}
-                        DEPENDS ${libname}
-                        COMMAND "${CMAKE_COMMAND}"
-                                -DCMAKE_INSTALL_COMPONENT=${libname}
-                                -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-      add_custom_target(install-${libname}-stripped
-                        DEPENDS ${libname}
-                        COMMAND "${CMAKE_COMMAND}"
-                                -DCMAKE_INSTALL_COMPONENT=${libname}
-                                -DCMAKE_INSTALL_DO_STRIP=1
-                                -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-      # If you have a parent target specified, we bind the new install target
-      # to the parent install target.
-      if(LIB_PARENT_TARGET)
-        add_dependencies(install-${LIB_PARENT_TARGET} install-${libname})
-        add_dependencies(install-${LIB_PARENT_TARGET}-stripped install-${libname}-stripped)
-      endif()
+    set(parent_target_arg)
+    if(LIB_PARENT_TARGET)
+      set(parent_target_arg PARENT_TARGET ${LIB_PARENT_TARGET})
     endif()
+    add_compiler_rt_install_targets(${libname} ${parent_target_arg})
+
     if(APPLE)
       set_target_properties(${libname} PROPERTIES
       OSX_ARCHITECTURES "${LIB_ARCHS_${libname}}")

Modified: compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake?rev=360181&r1=360180&r2=360181&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake Tue May  7 12:00:37 2019
@@ -1,4 +1,5 @@
 include(CMakeParseArguments)
+include(CompilerRTUtils)
 
 # On OS X SDKs can be installed anywhere on the base system and xcode-select can
 # set the default Xcode to use. This function finds the SDKs that are present in
@@ -249,10 +250,18 @@ function(darwin_lipo_libs name)
       )
     add_custom_target(${name}
       DEPENDS ${LIB_OUTPUT_DIR}/lib${name}.a)
+    set_target_properties(${name} PROPERTIES FOLDER "Compiler-RT Misc")
     add_dependencies(${LIB_PARENT_TARGET} ${name})
+
+    if(CMAKE_CONFIGURATION_TYPES)
+      set(install_component ${LIB_PARENT_TARGET})
+    else()
+      set(install_component ${name})
+    endif()
     install(FILES ${LIB_OUTPUT_DIR}/lib${name}.a
-      DESTINATION ${LIB_INSTALL_DIR})
-    set_target_properties(${name} PROPERTIES FOLDER "Compiler-RT Misc")
+      DESTINATION ${LIB_INSTALL_DIR}
+      COMPONENT ${install_component})
+    add_compiler_rt_install_targets(${name} PARENT_TARGET ${LIB_PARENT_TARGET})
   else()
     message(WARNING "Not generating lipo target for ${name} because no input libraries exist.")
   endif()

Modified: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake?rev=360181&r1=360180&r2=360181&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake Tue May  7 12:00:37 2019
@@ -415,3 +415,53 @@ function(compiler_rt_process_sources OUT
   endif()
   set("${OUTPUT_VAR}" ${sources} ${headers} PARENT_SCOPE)
 endfunction()
+
+# Create install targets for a library and its parent component (if specified).
+function(add_compiler_rt_install_targets name)
+  cmake_parse_arguments(ARG "" "PARENT_TARGET" "" ${ARGN})
+
+  if(ARG_PARENT_TARGET AND NOT TARGET install-${ARG_PARENT_TARGET})
+    # The parent install target specifies the parent component to scrape up
+    # anything not installed by the individual install targets, and to handle
+    # installation when running the multi-configuration generators.
+    add_custom_target(install-${ARG_PARENT_TARGET}
+                      DEPENDS ${ARG_PARENT_TARGET}
+                      COMMAND "${CMAKE_COMMAND}"
+                              -DCMAKE_INSTALL_COMPONENT=${ARG_PARENT_TARGET}
+                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+    add_custom_target(install-${ARG_PARENT_TARGET}-stripped
+                      DEPENDS ${ARG_PARENT_TARGET}
+                      COMMAND "${CMAKE_COMMAND}"
+                              -DCMAKE_INSTALL_COMPONENT=${ARG_PARENT_TARGET}
+                              -DCMAKE_INSTALL_DO_STRIP=1
+                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+    set_target_properties(install-${ARG_PARENT_TARGET} PROPERTIES
+                          FOLDER "Compiler-RT Misc")
+    set_target_properties(install-${ARG_PARENT_TARGET}-stripped PROPERTIES
+                          FOLDER "Compiler-RT Misc")
+    add_dependencies(install-compiler-rt install-${ARG_PARENT_TARGET})
+    add_dependencies(install-compiler-rt-stripped install-${ARG_PARENT_TARGET}-stripped)
+  endif()
+
+  # We only want to generate per-library install targets if you aren't using
+  # an IDE because the extra targets get cluttered in IDEs.
+  if(NOT CMAKE_CONFIGURATION_TYPES)
+    add_custom_target(install-${name}
+                      DEPENDS ${name}
+                      COMMAND "${CMAKE_COMMAND}"
+                              -DCMAKE_INSTALL_COMPONENT=${name}
+                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+    add_custom_target(install-${name}-stripped
+                      DEPENDS ${name}
+                      COMMAND "${CMAKE_COMMAND}"
+                              -DCMAKE_INSTALL_COMPONENT=${name}
+                              -DCMAKE_INSTALL_DO_STRIP=1
+                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+    # If you have a parent target specified, we bind the new install target
+    # to the parent install target.
+    if(LIB_PARENT_TARGET)
+      add_dependencies(install-${LIB_PARENT_TARGET} install-${name})
+      add_dependencies(install-${LIB_PARENT_TARGET}-stripped install-${name}-stripped)
+    endif()
+  endif()
+endfunction()




More information about the llvm-commits mailing list