1 include(LLVMProcessSources)
4 macro(add_llvm_library name)
5 llvm_process_sources( ALL_FILES ${ARGN} )
6 add_library( ${name} ${ALL_FILES} )
7 set( llvm_libs ${llvm_libs} ${name} PARENT_SCOPE)
8 set( llvm_lib_targets ${llvm_lib_targets} ${name} PARENT_SCOPE )
9 if( LLVM_COMMON_DEPENDS )
10 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
11 endif( LLVM_COMMON_DEPENDS )
12 install(TARGETS ${name}
13 LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
14 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
15 # The LLVM Target library shall be built before its sublibraries
16 # (asmprinter, etc) because those may use tablegenned files which
17 # generation is triggered by the main LLVM target library. Necessary
18 # for parallel builds:
19 if( CURRENT_LLVM_TARGET )
20 add_dependencies(${name} ${CURRENT_LLVM_TARGET})
22 endmacro(add_llvm_library name)
25 macro(add_llvm_executable name)
26 llvm_process_sources( ALL_FILES ${ARGN} )
27 add_executable(${name} ${ALL_FILES})
29 foreach(lib ${LLVM_USED_LIBS})
30 target_link_libraries( ${name} ${lib} )
32 endif( LLVM_USED_LIBS )
33 if( LLVM_LINK_COMPONENTS )
34 llvm_config(${name} ${LLVM_LINK_COMPONENTS})
35 endif( LLVM_LINK_COMPONENTS )
36 get_system_libs(llvm_system_libs)
37 if( llvm_system_libs )
38 target_link_libraries(${name} ${llvm_system_libs})
40 if( LLVM_COMMON_DEPENDS )
41 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
42 endif( LLVM_COMMON_DEPENDS )
43 endmacro(add_llvm_executable name)
46 macro(add_llvm_tool name)
47 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
48 add_llvm_executable(${name} ${ARGN})
49 install(TARGETS ${name}
50 RUNTIME DESTINATION bin)
51 endmacro(add_llvm_tool name)
54 macro(add_llvm_example name)
55 # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR})
56 add_llvm_executable(${name} ${ARGN})
57 install(TARGETS ${name}
58 RUNTIME DESTINATION examples)
59 endmacro(add_llvm_example name)
62 macro(add_llvm_target target_name)
64 add_custom_target(${target_name}Table_gen
65 DEPENDS ${TABLEGEN_OUTPUT})
66 add_dependencies(${target_name}Table_gen ${LLVM_COMMON_DEPENDS})
67 endif( TABLEGEN_OUTPUT )
68 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
69 add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT})
70 if ( TABLEGEN_OUTPUT )
71 add_dependencies(LLVM${target_name} ${target_name}Table_gen)
72 endif (TABLEGEN_OUTPUT)
73 set(CURRENT_LLVM_TARGET LLVM${target_name} PARENT_SCOPE)
74 endmacro(add_llvm_target)