1 include(GNUInstallDirs)
2 include(LLVMDistributionSupport)
4 macro(add_lld_library name)
5 cmake_parse_arguments(ARG
11 set(ARG_ENABLE_SHARED SHARED)
13 llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS})
15 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
16 get_target_export_arg(${name} LLD export_to_lldtargets)
17 install(TARGETS ${name}
19 ${export_to_lldtargets}
20 LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
21 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
22 RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
24 if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
25 add_llvm_install_targets(install-${name}
29 set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
31 endmacro(add_lld_library)
33 macro(add_lld_executable name)
34 add_llvm_executable(${name} ${ARGN})
35 endmacro(add_lld_executable)
37 macro(add_lld_tool name)
38 cmake_parse_arguments(ARG "DEPENDS;GENERATE_DRIVER" "" "" ${ARGN})
39 if (NOT LLD_BUILD_TOOLS)
40 set(EXCLUDE_FROM_ALL ON)
42 if(ARG_GENERATE_DRIVER
43 AND LLVM_TOOL_LLVM_DRIVER_BUILD
44 AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS)
46 set(get_obj_args ${ARGN})
47 list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$")
48 generate_llvm_objects(${name} ${get_obj_args})
49 add_custom_target(${name} DEPENDS llvm-driver)
51 add_lld_executable(${name} ${ARGN})
54 get_target_export_arg(${name} LLD export_to_lldtargets)
55 install(TARGETS ${name}
56 ${export_to_lldtargets}
57 RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
60 if(NOT CMAKE_CONFIGURATION_TYPES)
61 add_llvm_install_targets(install-${name}
65 set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
70 macro(add_lld_symlink name dest)
71 get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
72 if(LLVM_TOOL_LLVM_DRIVER_BUILD
73 AND ${dest} IN_LIST LLVM_DRIVER_TOOLS
74 AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${dest} IN_LIST LLVM_DISTRIBUTION_COMPONENTS)
76 set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${dest} ${name})
78 llvm_add_tool_symlink(LLD ${name} ${dest} ALWAYS_GENERATE)
79 # Always generate install targets
80 llvm_install_symlink(LLD ${name} ${dest} ALWAYS_GENERATE)