2012-06-21 09:30:21 +08:00
|
|
|
set( LLVM_LINK_COMPONENTS
|
|
|
|
${LLVM_TARGETS_TO_BUILD}
|
2013-12-10 20:40:37 +08:00
|
|
|
Analysis
|
2014-07-01 10:42:02 +08:00
|
|
|
CodeGen
|
2013-12-10 20:40:37 +08:00
|
|
|
Core
|
|
|
|
IPO
|
|
|
|
InstCombine
|
|
|
|
Instrumentation
|
|
|
|
MC
|
|
|
|
MCParser
|
|
|
|
ObjCARCOpts
|
|
|
|
Option
|
|
|
|
ScalarOpts
|
|
|
|
Support
|
|
|
|
TransformUtils
|
|
|
|
Vectorize
|
2012-06-21 09:30:21 +08:00
|
|
|
)
|
|
|
|
|
2014-03-11 01:00:46 +08:00
|
|
|
option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
|
2014-03-08 09:19:37 +08:00
|
|
|
|
|
|
|
# Support plugins. This must be before add_clang_executable as it reads
|
|
|
|
# LLVM_NO_DEAD_STRIP.
|
2014-03-11 01:00:46 +08:00
|
|
|
if(CLANG_PLUGIN_SUPPORT)
|
2014-03-08 09:19:37 +08:00
|
|
|
set(LLVM_NO_DEAD_STRIP 1)
|
|
|
|
endif()
|
2014-03-08 08:41:53 +08:00
|
|
|
|
2016-01-20 06:41:51 +08:00
|
|
|
add_clang_tool(clang
|
2012-06-21 09:30:21 +08:00
|
|
|
driver.cpp
|
|
|
|
cc1_main.cpp
|
|
|
|
cc1as_main.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(clang
|
2011-02-12 07:46:38 +08:00
|
|
|
clangBasic
|
2015-07-08 10:06:21 +08:00
|
|
|
clangCodeGen
|
2011-02-12 07:46:38 +08:00
|
|
|
clangDriver
|
|
|
|
clangFrontend
|
2013-12-10 20:40:37 +08:00
|
|
|
clangFrontendTool
|
2009-03-24 10:52:57 +08:00
|
|
|
)
|
|
|
|
|
2015-07-05 18:16:24 +08:00
|
|
|
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()
|
2014-03-08 09:19:37 +08:00
|
|
|
|
|
|
|
# Support plugins.
|
2014-03-11 01:00:46 +08:00
|
|
|
if(CLANG_PLUGIN_SUPPORT)
|
2015-03-20 01:45:12 +08:00
|
|
|
export_executable_symbols(clang)
|
2014-03-08 09:19:37 +08:00
|
|
|
endif()
|
2011-02-26 03:24:02 +08:00
|
|
|
|
2012-07-21 00:40:09 +08:00
|
|
|
add_dependencies(clang clang-headers)
|
|
|
|
|
2015-09-19 05:15:54 +08:00
|
|
|
if(NOT CLANG_LINKS_TO_CREATE)
|
2016-10-03 03:28:57 +08:00
|
|
|
set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
|
2015-09-22 06:44:57 +08:00
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl)
|
|
|
|
endif()
|
2015-09-19 05:15:54 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(link ${CLANG_LINKS_TO_CREATE})
|
|
|
|
add_clang_symlink(${link} clang)
|
|
|
|
endforeach()
|
2013-08-20 15:09:51 +08:00
|
|
|
|
|
|
|
# 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}")
|
2015-10-14 07:03:54 +08:00
|
|
|
set(TOOL_INFO_BUILD_VERSION "${LLVM_MAJOR_VERSION}.${LLVM_MINOR_VERSION}")
|
2013-08-20 15:09:51 +08:00
|
|
|
|
|
|
|
set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
|
|
|
|
target_link_libraries(clang
|
|
|
|
"-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()
|
2013-08-20 15:41:18 +08:00
|
|
|
|
2016-04-09 06:48:18 +08:00
|
|
|
# the linker -order_file flag is only supported by ld64
|
|
|
|
if(LD64_EXECUTABLE AND CLANG_ORDER_FILE)
|
|
|
|
include(CMakePushCheckState)
|
|
|
|
|
|
|
|
function(check_linker_flag flag out_var)
|
|
|
|
cmake_push_check_state()
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
|
|
|
|
check_cxx_compiler_flag("" ${out_var})
|
|
|
|
cmake_pop_check_state()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# This is a test to ensure the actual order file works with the linker.
|
|
|
|
check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}"
|
|
|
|
LINKER_ORDER_FILE_WORKS)
|
2016-08-11 08:19:51 +08:00
|
|
|
|
|
|
|
# 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)
|
2016-04-09 06:48:18 +08:00
|
|
|
target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
|
|
|
|
set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
|
|
|
|
endif()
|
2013-08-20 15:41:18 +08:00
|
|
|
endif()
|
|
|
|
|
2014-03-14 12:04:27 +08:00
|
|
|
if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
|
|
|
|
target_link_libraries(clang Polly)
|
|
|
|
endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
|