1set( LLVM_LINK_COMPONENTS 2 ${LLVM_TARGETS_TO_BUILD} 3 Analysis 4 CodeGen 5 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 18 ) 19 20option(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 28add_clang_executable(clang 29 driver.cpp 30 cc1_main.cpp 31 cc1as_main.cpp 32 ) 33 34target_link_libraries(clang 35 clangBasic 36 clangDriver 37 clangFrontend 38 clangFrontendTool 39 ) 40 41set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION}) 42 43# Support plugins. 44if(CLANG_PLUGIN_SUPPORT) 45 export_executable_symbols(clang) 46endif() 47 48add_dependencies(clang clang-headers) 49 50if(UNIX) 51 set(CLANGXX_LINK_OR_COPY create_symlink) 52# Create a relative symlink 53 set(clang_binary "clang${CMAKE_EXECUTABLE_SUFFIX}") 54else() 55 set(CLANGXX_LINK_OR_COPY copy) 56 set(clang_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX}") 57endif() 58 59# Create the clang++ symlink in the build directory. 60set(clang_pp "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}") 61add_custom_command(TARGET clang POST_BUILD 62 COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" "${clang_pp}" 63 WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}") 64 65set_property(DIRECTORY APPEND 66 PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_pp}) 67 68# Create the clang-cl symlink in the build directory. 69set(clang_cl "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl${CMAKE_EXECUTABLE_SUFFIX}") 70add_custom_command(TARGET clang POST_BUILD 71 COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" "${clang_cl}" 72 WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}") 73 74set_property(DIRECTORY APPEND 75 PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_cl}) 76 77install(TARGETS clang 78 RUNTIME DESTINATION bin) 79 80# Create the clang++ and clang-cl symlinks at installation time. 81install(SCRIPT clang_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\") 82 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() 109 110if(CLANG_ORDER_FILE) 111 target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}") 112endif() 113 114if(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) 122