1set( LLVM_LINK_COMPONENTS 2 ${LLVM_TARGETS_TO_BUILD} 3 Analysis 4 CodeGen 5 Core 6 IPO 7 InstCombine 8 Instrumentation 9 MC 10 MCParser 11 ObjCARCOpts 12 Option 13 ScalarOpts 14 Support 15 TransformUtils 16 Vectorize 17 ) 18 19option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON) 20 21# Support plugins. This must be before add_clang_executable as it reads 22# LLVM_NO_DEAD_STRIP. 23if(CLANG_PLUGIN_SUPPORT) 24 set(LLVM_NO_DEAD_STRIP 1) 25endif() 26 27add_clang_tool(clang 28 driver.cpp 29 cc1_main.cpp 30 cc1as_main.cpp 31 ) 32 33target_link_libraries(clang 34 clangBasic 35 clangCodeGen 36 clangDriver 37 clangFrontend 38 clangFrontendTool 39 ) 40 41if(WIN32 AND NOT CYGWIN) 42 # Prevent versioning if the buildhost is targeting for Win32. 43else() 44 set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION}) 45endif() 46 47# Support plugins. 48if(CLANG_PLUGIN_SUPPORT) 49 export_executable_symbols(clang) 50endif() 51 52add_dependencies(clang clang-headers) 53 54if(NOT CLANG_LINKS_TO_CREATE) 55 set(CLANG_LINKS_TO_CREATE clang++ clang-cl) 56 57 if (WIN32) 58 list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl) 59 endif() 60endif() 61 62foreach(link ${CLANG_LINKS_TO_CREATE}) 63 add_clang_symlink(${link} clang) 64endforeach() 65 66# Configure plist creation for OS X. 67set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name") 68if (APPLE) 69 if (CLANG_VENDOR) 70 set(TOOL_INFO_NAME "${CLANG_VENDOR} clang") 71 else() 72 set(TOOL_INFO_NAME "clang") 73 endif() 74 75 set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}") 76 set(TOOL_INFO_VERSION "${CLANG_VERSION}") 77 set(TOOL_INFO_BUILD_VERSION "${LLVM_MAJOR_VERSION}.${LLVM_MINOR_VERSION}") 78 79 set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}") 80 target_link_libraries(clang 81 "-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}") 82 configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY) 83 84 set(TOOL_INFO_UTI) 85 set(TOOL_INFO_NAME) 86 set(TOOL_INFO_VERSION) 87 set(TOOL_INFO_BUILD_VERSION) 88endif() 89 90# the linker -order_file flag is only supported by ld64 91if(LD64_EXECUTABLE AND CLANG_ORDER_FILE) 92 include(CMakePushCheckState) 93 94 function(check_linker_flag flag out_var) 95 cmake_push_check_state() 96 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") 97 check_cxx_compiler_flag("" ${out_var}) 98 cmake_pop_check_state() 99 endfunction() 100 101 # This is a test to ensure the actual order file works with the linker. 102 check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}" 103 LINKER_ORDER_FILE_WORKS) 104 105 if(LINKER_ORDER_FILE_WORKS) 106 target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}") 107 set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE}) 108 endif() 109endif() 110 111if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS) 112 target_link_libraries(clang Polly) 113 if(POLLY_LINK_LIBS) 114 foreach(lib ${POLLY_LINK_LIBS}) 115 target_link_libraries(clang ${lib}) 116 endforeach(lib) 117 endif(POLLY_LINK_LIBS) 118endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS) 119