189653704SJohn Ericsoninclude(GNUInstallDirs) 256f7e5a8SShoaib Meenaiinclude(LLVMDistributionSupport) 356f7e5a8SShoaib Meenai 4f367a2a5SPetr Hosekmacro(add_lld_library name) 5dbcc04a5SPavel Labath cmake_parse_arguments(ARG 6dbcc04a5SPavel Labath "SHARED" 7dbcc04a5SPavel Labath "" 8dbcc04a5SPavel Labath "" 9dbcc04a5SPavel Labath ${ARGN}) 10dbcc04a5SPavel Labath if(ARG_SHARED) 11dbcc04a5SPavel Labath set(ARG_ENABLE_SHARED SHARED) 12dbcc04a5SPavel Labath endif() 13dbcc04a5SPavel Labath llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS}) 14dbcc04a5SPavel Labath 153e77b20dSDavid Zarzycki if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 1656f7e5a8SShoaib Meenai get_target_export_arg(${name} LLD export_to_lldtargets) 17dbcc04a5SPavel Labath install(TARGETS ${name} 18dbcc04a5SPavel Labath COMPONENT ${name} 19dbcc04a5SPavel Labath ${export_to_lldtargets} 20e941b031SJohn Ericson LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 21e941b031SJohn Ericson ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} 2289653704SJohn Ericson RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") 23dbcc04a5SPavel Labath 24dbcc04a5SPavel Labath if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES) 25d6d11f3cSShoaib Meenai add_llvm_install_targets(install-${name} 26dbcc04a5SPavel Labath DEPENDS ${name} 27d6d11f3cSShoaib Meenai COMPONENT ${name}) 28dbcc04a5SPavel Labath endif() 29dbcc04a5SPavel Labath set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name}) 30dbcc04a5SPavel Labath endif() 31f367a2a5SPetr Hosekendmacro(add_lld_library) 32f367a2a5SPetr Hosek 33f367a2a5SPetr Hosekmacro(add_lld_executable name) 34f367a2a5SPetr Hosek add_llvm_executable(${name} ${ARGN}) 35f367a2a5SPetr Hosekendmacro(add_lld_executable) 36f367a2a5SPetr Hosek 37f367a2a5SPetr Hosekmacro(add_lld_tool name) 38*4cee0e3cSAlexandre Ganea cmake_parse_arguments(ARG "DEPENDS;GENERATE_DRIVER" "" "" ${ARGN}) 39f367a2a5SPetr Hosek if (NOT LLD_BUILD_TOOLS) 40f367a2a5SPetr Hosek set(EXCLUDE_FROM_ALL ON) 41f367a2a5SPetr Hosek endif() 42*4cee0e3cSAlexandre Ganea if(ARG_GENERATE_DRIVER 43*4cee0e3cSAlexandre Ganea AND LLVM_TOOL_LLVM_DRIVER_BUILD 44*4cee0e3cSAlexandre Ganea AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS) 45*4cee0e3cSAlexandre Ganea ) 46*4cee0e3cSAlexandre Ganea set(get_obj_args ${ARGN}) 47*4cee0e3cSAlexandre Ganea list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$") 48*4cee0e3cSAlexandre Ganea generate_llvm_objects(${name} ${get_obj_args}) 49*4cee0e3cSAlexandre Ganea add_custom_target(${name} DEPENDS llvm-driver) 50*4cee0e3cSAlexandre Ganea else() 51f367a2a5SPetr Hosek add_lld_executable(${name} ${ARGN}) 52f367a2a5SPetr Hosek 53f367a2a5SPetr Hosek if (LLD_BUILD_TOOLS) 5456f7e5a8SShoaib Meenai get_target_export_arg(${name} LLD export_to_lldtargets) 55f367a2a5SPetr Hosek install(TARGETS ${name} 56f367a2a5SPetr Hosek ${export_to_lldtargets} 5789653704SJohn Ericson RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" 58f367a2a5SPetr Hosek COMPONENT ${name}) 59f367a2a5SPetr Hosek 60f367a2a5SPetr Hosek if(NOT CMAKE_CONFIGURATION_TYPES) 61d6d11f3cSShoaib Meenai add_llvm_install_targets(install-${name} 62f367a2a5SPetr Hosek DEPENDS ${name} 63d6d11f3cSShoaib Meenai COMPONENT ${name}) 64f367a2a5SPetr Hosek endif() 65f367a2a5SPetr Hosek set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name}) 66f367a2a5SPetr Hosek endif() 67*4cee0e3cSAlexandre Ganea endif() 68f367a2a5SPetr Hosekendmacro() 69f367a2a5SPetr Hosek 70f367a2a5SPetr Hosekmacro(add_lld_symlink name dest) 71*4cee0e3cSAlexandre Ganea get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS) 72*4cee0e3cSAlexandre Ganea if(LLVM_TOOL_LLVM_DRIVER_BUILD 73*4cee0e3cSAlexandre Ganea AND ${dest} IN_LIST LLVM_DRIVER_TOOLS 74*4cee0e3cSAlexandre Ganea AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${dest} IN_LIST LLVM_DISTRIBUTION_COMPONENTS) 75*4cee0e3cSAlexandre Ganea ) 76*4cee0e3cSAlexandre Ganea set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${dest} ${name}) 77*4cee0e3cSAlexandre Ganea else() 7807b74980SJohn Ericson llvm_add_tool_symlink(LLD ${name} ${dest} ALWAYS_GENERATE) 79f367a2a5SPetr Hosek # Always generate install targets 8007b74980SJohn Ericson llvm_install_symlink(LLD ${name} ${dest} ALWAYS_GENERATE) 81*4cee0e3cSAlexandre Ganea endif() 82f367a2a5SPetr Hosekendmacro() 83