blob: a46dcce9103f8f585e04fe01dbbd7422b25e01b9 [file] [log] [blame]
Oscar Fuentes3d01fc72008-09-22 01:08:49 +00001include(LLVMConfig)
2
3macro(add_llvm_library name)
4 add_library( ${name} ${ARGN} )
5 set( llvm_libs ${llvm_libs} ${name} PARENT_SCOPE)
Oscar Fuentes1d8e4cf2008-09-22 18:21:51 +00006 set( llvm_lib_targets ${llvm_lib_targets} ${name} PARENT_SCOPE )
7 if( LLVM_COMMON_DEPENDS )
8 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
9 endif( LLVM_COMMON_DEPENDS )
Oscar Fuentes1dc97162008-10-22 02:56:07 +000010 install(TARGETS ${name}
11 LIBRARY DESTINATION lib
12 ARCHIVE DESTINATION lib)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000013endmacro(add_llvm_library name)
14
15
16macro(add_llvm_executable name)
17 add_executable(${name} ${ARGN})
Oscar Fuentesbcc1db52008-10-26 00:51:05 +000018 if( LLVM_USED_LIBS )
19 foreach(lib ${LLVM_USED_LIBS})
20 target_link_libraries( ${name} ${lib} )
21 endforeach(lib)
22 endif( LLVM_USED_LIBS )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000023 if( LLVM_LINK_COMPONENTS )
24 llvm_config(${name} ${LLVM_LINK_COMPONENTS})
25 endif( LLVM_LINK_COMPONENTS )
26 if( MSVC )
27 target_link_libraries(${name} ${llvm_libs})
28 else( MSVC )
29 add_dependencies(${name} llvm-config.target)
30 set_target_properties(${name}
31 PROPERTIES
32 LINK_FLAGS "-L ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
33 if( MINGW )
34 target_link_libraries(${name} DbgHelp psapi)
35 elseif( CMAKE_HOST_UNIX )
36 target_link_libraries(${name} dl)
37 endif( MINGW )
38 endif( MSVC )
39endmacro(add_llvm_executable name)
40
41
42macro(add_llvm_tool name)
43 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
44 add_llvm_executable(${name} ${ARGN})
Oscar Fuentes1dc97162008-10-22 02:56:07 +000045 install(TARGETS ${name}
46 RUNTIME DESTINATION bin)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000047endmacro(add_llvm_tool name)
48
49
50macro(add_llvm_example name)
51# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR})
52 add_llvm_executable(${name} ${ARGN})
Oscar Fuentes1dc97162008-10-22 02:56:07 +000053 install(TARGETS ${name}
54 RUNTIME DESTINATION examples)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000055endmacro(add_llvm_example name)
Oscar Fuentese1ad0872008-09-26 04:40:32 +000056
57
58macro(add_llvm_target target_name)
59 if( TABLEGEN_OUTPUT )
60 add_custom_target(${target_name}Table_gen
61 DEPENDS ${TABLEGEN_OUTPUT})
62 add_dependencies(${target_name}Table_gen ${LLVM_COMMON_DEPENDS})
63 endif( TABLEGEN_OUTPUT )
64 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
65 add_partially_linked_object(LLVM${target_name} ${ARGN})
66 if( TABLEGEN_OUTPUT )
67 add_dependencies(LLVM${target_name} ${target_name}Table_gen)
68 endif( TABLEGEN_OUTPUT )
69endmacro(add_llvm_target)