Home | History | Annotate | Download | only in driver
      1 set( 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   ProfileData
     15   ScalarOpts
     16   Support
     17   TransformUtils
     18   Vectorize
     19   )
     20 
     21 option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
     22 
     23 # Support plugins. This must be before add_clang_executable as it reads
     24 # LLVM_NO_DEAD_STRIP.
     25 if(CLANG_PLUGIN_SUPPORT)
     26   set(LLVM_NO_DEAD_STRIP 1)
     27 endif()
     28 
     29 add_clang_executable(clang
     30   driver.cpp
     31   cc1_main.cpp
     32   cc1as_main.cpp
     33   )
     34 
     35 target_link_libraries(clang
     36   clangBasic
     37   clangDriver
     38   clangFrontend
     39   clangFrontendTool
     40   )
     41 
     42 set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
     43 
     44 # Support plugins.
     45 if(CLANG_PLUGIN_SUPPORT)
     46   set_target_properties(clang PROPERTIES ENABLE_EXPORTS 1)
     47 endif()
     48 
     49 add_dependencies(clang clang-headers)
     50 
     51 if(UNIX)
     52   set(CLANGXX_LINK_OR_COPY create_symlink)
     53 # Create a relative symlink
     54   set(clang_binary "clang${CMAKE_EXECUTABLE_SUFFIX}")
     55 else()
     56   set(CLANGXX_LINK_OR_COPY copy)
     57   set(clang_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
     58 endif()
     59 
     60 # Create the clang++ symlink in the build directory.
     61 set(clang_pp "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}")
     62 add_custom_command(TARGET clang POST_BUILD
     63     COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" "${clang_pp}"
     64     WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
     65 
     66 set_property(DIRECTORY APPEND
     67   PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_pp})
     68 
     69 # Create the clang-cl symlink in the build directory.
     70 set(clang_cl "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl${CMAKE_EXECUTABLE_SUFFIX}")
     71 add_custom_command(TARGET clang POST_BUILD
     72     COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" "${clang_cl}"
     73     WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
     74 
     75 set_property(DIRECTORY APPEND
     76   PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_cl})
     77 
     78 install(TARGETS clang
     79   RUNTIME DESTINATION bin)
     80 
     81 # Create the clang++ and clang-cl symlinks at installation time.
     82 install(SCRIPT clang_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
     83 
     84 # Configure plist creation for OS X.
     85 set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
     86 if (APPLE)  
     87   if (CLANG_VENDOR)
     88     set(TOOL_INFO_NAME "${CLANG_VENDOR} clang")
     89   else()
     90     set(TOOL_INFO_NAME "clang")
     91   endif()
     92 
     93   set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}")
     94   set(TOOL_INFO_VERSION "${CLANG_VERSION}")
     95   if (LLVM_SUBMIT_VERSION)
     96     set(TOOL_INFO_BUILD_VERSION
     97       "${LLVM_SUBMIT_VERSION}.${LLVM_SUBMIT_SUBVERSION}")
     98   endif()
     99   
    100   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
    101   target_link_libraries(clang
    102     "-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
    103   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
    104   
    105   set(TOOL_INFO_UTI)
    106   set(TOOL_INFO_NAME)
    107   set(TOOL_INFO_VERSION)
    108   set(TOOL_INFO_BUILD_VERSION)
    109 endif()
    110 
    111 if(CLANG_ORDER_FILE)
    112   target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
    113 endif()
    114 
    115 if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
    116   target_link_libraries(clang Polly)
    117   if(POLLY_LINK_LIBS)
    118     foreach(lib ${POLLY_LINK_LIBS})
    119       target_link_libraries(clang ${lib})
    120     endforeach(lib)
    121   endif(POLLY_LINK_LIBS)
    122 endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
    123