1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
set( LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Analysis
CAS
CodeGen
Core
IPO
AggressiveInstCombine
InstCombine
Instrumentation
MC
MCParser
ObjCARCOpts
Option
ScalarOpts
Support
TargetParser
TransformUtils
Vectorize
)
# Support plugins.
if(CLANG_PLUGIN_SUPPORT)
set(support_plugins SUPPORT_PLUGINS)
endif()
add_clang_tool(clang
driver.cpp
CacheLauncherMode.cpp
cc1_main.cpp
cc1as_main.cpp
cc1gen_reproducer_main.cpp
cc1depscanProtocol.cpp
cc1depscan_main.cpp
DEPENDS
intrinsics_gen
${support_plugins}
GENERATE_DRIVER
)
clang_target_link_libraries(clang
PRIVATE
clangAPINotes
clangBasic
clangCAS
clangCodeGen
clangDependencyScanning
clangDriver
clangFrontend
clangFrontendTool
clangSerialization
)
if(WIN32 AND NOT CYGWIN)
# Prevent versioning if the buildhost is targeting for Win32.
else()
set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
endif()
# Support plugins.
if(CLANG_PLUGIN_SUPPORT)
export_executable_symbols_for_plugins(clang)
endif()
add_dependencies(clang clang-resource-headers)
if(NOT CLANG_LINKS_TO_CREATE)
set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
endif()
if (CLANG_ENABLE_HLSL)
set(HLSL_LINK clang-dxc)
endif()
foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK})
add_clang_symlink(${link} clang)
endforeach()
# Adding `clang-cache` tool as a symlink to clang.
add_clang_symlink(clang-cache clang)
# Configure plist creation for OS X.
set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
if (APPLE)
if (CLANG_VENDOR)
set(TOOL_INFO_NAME "${CLANG_VENDOR} clang")
else()
set(TOOL_INFO_NAME "clang")
endif()
set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}")
set(TOOL_INFO_VERSION "${CLANG_VERSION}")
set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
if(LLVM_TOOL_LLVM_DRIVER_BUILD AND clang IN_LIST LLVM_DRIVER_TOOLS)
set(TARGET_NAME llvm-driver)
else()
set(TARGET_NAME clang)
endif()
target_link_libraries(${TARGET_NAME}
PRIVATE
"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
set(TOOL_INFO_UTI)
set(TOOL_INFO_NAME)
set(TOOL_INFO_VERSION)
set(TOOL_INFO_BUILD_VERSION)
endif()
if(CLANG_ORDER_FILE AND
(LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
include(LLVMCheckLinkerFlag)
if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
elseif (LLVM_LINKER_IS_GOLD)
set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")
elseif (LLVM_LINKER_IS_LLD)
set(LINKER_ORDER_FILE_OPTION "-Wl,--symbol-ordering-file,${CLANG_ORDER_FILE}")
endif()
# This is a test to ensure the actual order file works with the linker.
llvm_check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
# Passing an empty order file disables some linker layout optimizations.
# To work around this and enable workflows for re-linking when the order file
# changes we check during configuration if the file is empty, and make it a
# configuration dependency.
file(READ ${CLANG_ORDER_FILE} ORDER_FILE LIMIT 20)
if("${ORDER_FILE}" STREQUAL "\n")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLANG_ORDER_FILE})
elseif(LINKER_ORDER_FILE_WORKS)
target_link_libraries(clang PRIVATE ${LINKER_ORDER_FILE_OPTION})
set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
endif()
endif()
# Add features.json file into usr/share/clang
set(features_file_src "${CMAKE_CURRENT_SOURCE_DIR}/features.json")
set(features_file_dest "${CMAKE_BINARY_DIR}/share/clang/features.json")
configure_file(${features_file_src} ${features_file_dest} @ONLY)
add_custom_target(clang-features-file DEPENDS ${features_file_dest})
add_dependencies(clang clang-features-file)
install(FILES ${features_file_dest}
DESTINATION "share/clang"
COMPONENT clang-features-file)
if(NOT LLVM_ENABLE_IDE)
add_llvm_install_targets("install-clang-features-file"
DEPENDS clang-features-file
COMPONENT clang-features-file)
endif()
|