1macro(add_lld_library name)
2  cmake_parse_arguments(ARG
3    "SHARED"
4    ""
5    ""
6    ${ARGN})
7  if(ARG_SHARED)
8    set(ARG_ENABLE_SHARED SHARED)
9  endif()
10  llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS})
11  set_target_properties(${name} PROPERTIES FOLDER "lld libraries")
12
13  if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
14    if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
15        NOT LLVM_DISTRIBUTION_COMPONENTS)
16      set(export_to_lldtargets EXPORT LLDTargets)
17      set_property(GLOBAL PROPERTY LLD_HAS_EXPORTS True)
18    endif()
19
20    install(TARGETS ${name}
21      COMPONENT ${name}
22      ${export_to_lldtargets}
23      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
24      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
25      RUNTIME DESTINATION bin)
26
27    if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
28      add_llvm_install_targets(install-${name}
29        DEPENDS ${name}
30        COMPONENT ${name})
31    endif()
32    set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
33  endif()
34endmacro(add_lld_library)
35
36macro(add_lld_executable name)
37  add_llvm_executable(${name} ${ARGN})
38  set_target_properties(${name} PROPERTIES FOLDER "lld executables")
39endmacro(add_lld_executable)
40
41macro(add_lld_tool name)
42  if (NOT LLD_BUILD_TOOLS)
43    set(EXCLUDE_FROM_ALL ON)
44  endif()
45
46  add_lld_executable(${name} ${ARGN})
47
48  if (LLD_BUILD_TOOLS)
49    if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
50        NOT LLVM_DISTRIBUTION_COMPONENTS)
51      set(export_to_lldtargets EXPORT LLDTargets)
52      set_property(GLOBAL PROPERTY LLD_HAS_EXPORTS True)
53    endif()
54
55    install(TARGETS ${name}
56      ${export_to_lldtargets}
57      RUNTIME DESTINATION bin
58      COMPONENT ${name})
59
60    if(NOT CMAKE_CONFIGURATION_TYPES)
61      add_llvm_install_targets(install-${name}
62        DEPENDS ${name}
63        COMPONENT ${name})
64    endif()
65    set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
66  endif()
67endmacro()
68
69macro(add_lld_symlink name dest)
70  add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
71  # Always generate install targets
72  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
73endmacro()
74