blob: 805aebfac3a7389f80da60e02c6030c04c962467 [file] [log] [blame]
Chandler Carruthb0d86712012-06-21 01:30:21 +00001set( LLVM_LINK_COMPONENTS
2 ${LLVM_TARGETS_TO_BUILD}
Stephen Hines651f13c2014-04-23 16:59:28 -07003 Analysis
Stephen Hinesc568f1e2014-07-21 00:47:37 -07004 CodeGen
Stephen Hines651f13c2014-04-23 16:59:28 -07005 Core
6 IPA
7 IPO
8 InstCombine
9 Instrumentation
10 MC
11 MCParser
12 ObjCARCOpts
13 Option
14 ScalarOpts
15 Support
16 TransformUtils
17 Vectorize
Chandler Carruthb0d86712012-06-21 01:30:21 +000018 )
19
Stephen Hines651f13c2014-04-23 16:59:28 -070020option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
21
22# Support plugins. This must be before add_clang_executable as it reads
23# LLVM_NO_DEAD_STRIP.
24if(CLANG_PLUGIN_SUPPORT)
25 set(LLVM_NO_DEAD_STRIP 1)
26endif()
27
Chandler Carruthb0d86712012-06-21 01:30:21 +000028add_clang_executable(clang
29 driver.cpp
30 cc1_main.cpp
31 cc1as_main.cpp
32 )
33
34target_link_libraries(clang
Jeffrey Yasskin0a86d442011-02-11 23:46:38 +000035 clangBasic
Jeffrey Yasskin0a86d442011-02-11 23:46:38 +000036 clangDriver
37 clangFrontend
Stephen Hines651f13c2014-04-23 16:59:28 -070038 clangFrontendTool
Daniel Dunbarcbcd98b2009-03-24 02:52:57 +000039 )
40
Douglas Gregor8435bf92011-02-25 19:24:02 +000041set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
Stephen Hines651f13c2014-04-23 16:59:28 -070042
43# Support plugins.
44if(CLANG_PLUGIN_SUPPORT)
45 set_target_properties(clang PROPERTIES ENABLE_EXPORTS 1)
46endif()
Douglas Gregor8435bf92011-02-25 19:24:02 +000047
NAKAMURA Takumi675a4e12012-07-20 16:40:09 +000048add_dependencies(clang clang-headers)
49
Douglas Gregor6cef99d2009-11-19 16:42:34 +000050if(UNIX)
51 set(CLANGXX_LINK_OR_COPY create_symlink)
Dylan Noblesmith3d9000d2012-02-09 20:02:46 +000052# Create a relative symlink
53 set(clang_binary "clang${CMAKE_EXECUTABLE_SUFFIX}")
Douglas Gregor6cef99d2009-11-19 16:42:34 +000054else()
55 set(CLANGXX_LINK_OR_COPY copy)
Stephen Hines651f13c2014-04-23 16:59:28 -070056 set(clang_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
Douglas Gregor6cef99d2009-11-19 16:42:34 +000057endif()
58
Douglas Gregorc720a4d2009-11-19 05:46:45 +000059# Create the clang++ symlink in the build directory.
Stephen Hines651f13c2014-04-23 16:59:28 -070060set(clang_pp "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}")
Peter Collingbourne82c34602011-11-21 00:00:48 +000061add_custom_command(TARGET clang POST_BUILD
Stephen Hines651f13c2014-04-23 16:59:28 -070062 COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" "${clang_pp}"
63 WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
Douglas Gregor8435bf92011-02-25 19:24:02 +000064
Oscar Fuentes839e61a2011-02-05 21:37:37 +000065set_property(DIRECTORY APPEND
66 PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_pp})
Douglas Gregorc720a4d2009-11-19 05:46:45 +000067
Hans Wennborgc2f531a2013-07-19 20:33:20 +000068# Create the clang-cl symlink in the build directory.
Stephen Hines651f13c2014-04-23 16:59:28 -070069set(clang_cl "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl${CMAKE_EXECUTABLE_SUFFIX}")
Hans Wennborgc2f531a2013-07-19 20:33:20 +000070add_custom_command(TARGET clang POST_BUILD
Stephen Hines651f13c2014-04-23 16:59:28 -070071 COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" "${clang_cl}"
72 WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
Hans Wennborgc2f531a2013-07-19 20:33:20 +000073
74set_property(DIRECTORY APPEND
75 PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_cl})
76
Douglas Gregor7f7b7482009-08-23 05:28:29 +000077install(TARGETS clang
78 RUNTIME DESTINATION bin)
Douglas Gregorc720a4d2009-11-19 05:46:45 +000079
Hans Wennborgc2f531a2013-07-19 20:33:20 +000080# Create the clang++ and clang-cl symlinks at installation time.
Oscar Fuentesfbfe8992010-10-17 16:10:32 +000081install(SCRIPT clang_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
Michael Gottesman48576382013-08-20 07:09:51 +000082
83# Configure plist creation for OS X.
84set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
85if (APPLE)
86 if (CLANG_VENDOR)
87 set(TOOL_INFO_NAME "${CLANG_VENDOR} clang")
88 else()
89 set(TOOL_INFO_NAME "clang")
90 endif()
91
92 set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}")
93 set(TOOL_INFO_VERSION "${CLANG_VERSION}")
94 if (LLVM_SUBMIT_VERSION)
95 set(TOOL_INFO_BUILD_VERSION
96 "${LLVM_SUBMIT_VERSION}.${LLVM_SUBMIT_SUBVERSION}")
97 endif()
98
99 set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
100 target_link_libraries(clang
101 "-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
102 configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
103
104 set(TOOL_INFO_UTI)
105 set(TOOL_INFO_NAME)
106 set(TOOL_INFO_VERSION)
107 set(TOOL_INFO_BUILD_VERSION)
108endif()
Michael Gottesmanf65456f2013-08-20 07:41:18 +0000109
110if(CLANG_ORDER_FILE)
111 target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
112endif()
113
Stephen Hines651f13c2014-04-23 16:59:28 -0700114if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
115 target_link_libraries(clang Polly)
116 if(POLLY_LINK_LIBS)
117 foreach(lib ${POLLY_LINK_LIBS})
118 target_link_libraries(clang ${lib})
119 endforeach(lib)
120 endif(POLLY_LINK_LIBS)
121endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)