blob: c531298a30f043ff9a5004ffe6b03393f884b574 [file] [log] [blame]
Oscar Fuentes1bbdd462008-11-14 22:06:14 +00001include(LLVMProcessSources)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +00002include(LLVMConfig)
3
4macro(add_llvm_library name)
Oscar Fuentes50925fb2008-11-15 02:08:08 +00005 llvm_process_sources( ALL_FILES ${ARGN} )
6 add_library( ${name} ${ALL_FILES} )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +00007 set( llvm_libs ${llvm_libs} ${name} PARENT_SCOPE)
Oscar Fuentes1d8e4cf2008-09-22 18:21:51 +00008 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 )
Oscar Fuentes1dc97162008-10-22 02:56:07 +000012 install(TARGETS ${name}
13 LIBRARY DESTINATION lib
14 ARCHIVE DESTINATION lib)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000015endmacro(add_llvm_library name)
16
17
18macro(add_llvm_executable name)
Oscar Fuentes50925fb2008-11-15 02:08:08 +000019 llvm_process_sources( ALL_FILES ${ARGN} )
20 add_executable(${name} ${ALL_FILES})
Oscar Fuentesbcc1db52008-10-26 00:51:05 +000021 if( LLVM_USED_LIBS )
22 foreach(lib ${LLVM_USED_LIBS})
23 target_link_libraries( ${name} ${lib} )
24 endforeach(lib)
25 endif( LLVM_USED_LIBS )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000026 if( LLVM_LINK_COMPONENTS )
27 llvm_config(${name} ${LLVM_LINK_COMPONENTS})
28 endif( LLVM_LINK_COMPONENTS )
29 if( MSVC )
30 target_link_libraries(${name} ${llvm_libs})
31 else( MSVC )
32 add_dependencies(${name} llvm-config.target)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000033 endif( MSVC )
Oscar Fuentes1a53cbf2009-05-27 15:49:33 +000034 get_system_libs(llvm_system_libs)
35 if( llvm_system_libs )
36 target_link_libraries(${name} ${llvm_system_libs})
37 endif()
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000038endmacro(add_llvm_executable name)
39
40
41macro(add_llvm_tool name)
42 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
43 add_llvm_executable(${name} ${ARGN})
Oscar Fuentes1dc97162008-10-22 02:56:07 +000044 install(TARGETS ${name}
45 RUNTIME DESTINATION bin)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000046endmacro(add_llvm_tool name)
47
48
49macro(add_llvm_example name)
50# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR})
51 add_llvm_executable(${name} ${ARGN})
Oscar Fuentes1dc97162008-10-22 02:56:07 +000052 install(TARGETS ${name}
53 RUNTIME DESTINATION examples)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000054endmacro(add_llvm_example name)
Oscar Fuentese1ad0872008-09-26 04:40:32 +000055
56
57macro(add_llvm_target target_name)
58 if( TABLEGEN_OUTPUT )
59 add_custom_target(${target_name}Table_gen
60 DEPENDS ${TABLEGEN_OUTPUT})
61 add_dependencies(${target_name}Table_gen ${LLVM_COMMON_DEPENDS})
62 endif( TABLEGEN_OUTPUT )
63 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
64 add_partially_linked_object(LLVM${target_name} ${ARGN})
65 if( TABLEGEN_OUTPUT )
66 add_dependencies(LLVM${target_name} ${target_name}Table_gen)
67 endif( TABLEGEN_OUTPUT )
68endmacro(add_llvm_target)