[lld] r290391 - [CMake] Add install target for the lld tool

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 16:22:47 PST 2016


Author: phosek
Date: Thu Dec 22 18:22:47 2016
New Revision: 290391

URL: http://llvm.org/viewvc/llvm-project?rev=290391&view=rev
Log:
[CMake] Add install target for the lld tool

This is necessary for the distribution targets which assume that
each component has an install target. This also moves the CMake
macros into a separate file akin to other LLVM projects.

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

Added:
    lld/trunk/cmake/modules/AddLLD.cmake
Modified:
    lld/trunk/CMakeLists.txt
    lld/trunk/tools/lld/CMakeLists.txt

Modified: lld/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/CMakeLists.txt?rev=290391&r1=290390&r2=290391&view=diff
==============================================================================
--- lld/trunk/CMakeLists.txt (original)
+++ lld/trunk/CMakeLists.txt Thu Dec 22 18:22:47 2016
@@ -106,6 +106,8 @@ endif()
 
 list (APPEND CMAKE_MODULE_PATH "${LLD_SOURCE_DIR}/cmake/modules")
 
+include(AddLLD)
+
 option(LLD_USE_VTUNE
        "Enable VTune user task tracking."
        OFF)
@@ -118,6 +120,8 @@ if (LLD_USE_VTUNE)
   endif()
 endif()
 
+option(LLD_BUILD_TOOLS
+  "Build the lld tools. If OFF, just generate build targets." ON)
 
 if (MSVC)
   add_definitions(-wd4530) # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.'
@@ -138,12 +142,6 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
     )
 endif()
 
-macro(add_lld_library name)
-  add_llvm_library(${name} ${ARGN})
-  set_target_properties(${name} PROPERTIES FOLDER "lld libraries")
-endmacro(add_lld_library)
-
-
 add_subdirectory(lib)
 add_subdirectory(tools/lld)
 

Added: lld/trunk/cmake/modules/AddLLD.cmake
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/cmake/modules/AddLLD.cmake?rev=290391&view=auto
==============================================================================
--- lld/trunk/cmake/modules/AddLLD.cmake (added)
+++ lld/trunk/cmake/modules/AddLLD.cmake Thu Dec 22 18:22:47 2016
@@ -0,0 +1,45 @@
+macro(add_lld_library name)
+  add_llvm_library(${name} ${ARGN})
+  set_target_properties(${name} PROPERTIES FOLDER "lld libraries")
+endmacro(add_lld_library)
+
+macro(add_lld_executable name)
+  add_llvm_executable(${name} ${ARGN})
+  set_target_properties(${name} PROPERTIES FOLDER "lld executables")
+endmacro(add_lld_executable)
+
+macro(add_lld_tool name)
+  if (NOT LLD_BUILD_TOOLS)
+    set(EXCLUDE_FROM_ALL ON)
+  endif()
+
+  add_lld_executable(${name} ${ARGN})
+
+  if (LLD_BUILD_TOOLS)
+    if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+        NOT LLVM_DISTRIBUTION_COMPONENTS)
+      set(export_to_lldtargets EXPORT lldTargets)
+      set_property(GLOBAL PROPERTY LLD_HAS_EXPORTS True)
+    endif()
+
+    install(TARGETS ${name}
+      ${export_to_lldtargets}
+      RUNTIME DESTINATION bin
+      COMPONENT ${name})
+
+    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")
+    endif()
+    set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
+  endif()
+endmacro()
+
+macro(add_lld_symlink name dest)
+  add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
+  # Always generate install targets
+  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+endmacro()

Modified: lld/trunk/tools/lld/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld/CMakeLists.txt?rev=290391&r1=290390&r2=290391&view=diff
==============================================================================
--- lld/trunk/tools/lld/CMakeLists.txt (original)
+++ lld/trunk/tools/lld/CMakeLists.txt Thu Dec 22 18:22:47 2016
@@ -1,4 +1,4 @@
-add_llvm_executable(lld
+add_lld_tool(lld
   lld.cpp
   )
 
@@ -17,8 +17,5 @@ if(NOT LLD_SYMLINKS_TO_CREATE)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
-  add_llvm_tool_symlink(${link} lld ALWAYS_GENERATE)
-  # Always generate install targets
-  llvm_install_symlink(${link} lld ALWAYS_GENERATE)
+  add_lld_symlink(${link} lld)
 endforeach()
-




More information about the llvm-commits mailing list