Oscar Fuentes | 1bbdd46 | 2008-11-14 22:06:14 +0000 | [diff] [blame] | 1 | include(LLVMProcessSources) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 2 | include(LLVMConfig) |
| 3 | |
| 4 | macro(add_llvm_library name) |
Oscar Fuentes | 50925fb | 2008-11-15 02:08:08 +0000 | [diff] [blame] | 5 | llvm_process_sources( ALL_FILES ${ARGN} ) |
| 6 | add_library( ${name} ${ALL_FILES} ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 7 | set( llvm_libs ${llvm_libs} ${name} PARENT_SCOPE) |
Oscar Fuentes | 1d8e4cf | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 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 ) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 12 | install(TARGETS ${name} |
| 13 | LIBRARY DESTINATION lib |
| 14 | ARCHIVE DESTINATION lib) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 15 | endmacro(add_llvm_library name) |
| 16 | |
| 17 | |
| 18 | macro(add_llvm_executable name) |
Oscar Fuentes | 50925fb | 2008-11-15 02:08:08 +0000 | [diff] [blame] | 19 | llvm_process_sources( ALL_FILES ${ARGN} ) |
| 20 | add_executable(${name} ${ALL_FILES}) |
Oscar Fuentes | bcc1db5 | 2008-10-26 00:51:05 +0000 | [diff] [blame] | 21 | 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 Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 26 | 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 Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 33 | endif( MSVC ) |
Oscar Fuentes | 1a53cbf | 2009-05-27 15:49:33 +0000 | [diff] [blame^] | 34 | get_system_libs(llvm_system_libs) |
| 35 | if( llvm_system_libs ) |
| 36 | target_link_libraries(${name} ${llvm_system_libs}) |
| 37 | endif() |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 38 | endmacro(add_llvm_executable name) |
| 39 | |
| 40 | |
| 41 | macro(add_llvm_tool name) |
| 42 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) |
| 43 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 44 | install(TARGETS ${name} |
| 45 | RUNTIME DESTINATION bin) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 46 | endmacro(add_llvm_tool name) |
| 47 | |
| 48 | |
| 49 | macro(add_llvm_example name) |
| 50 | # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR}) |
| 51 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 52 | install(TARGETS ${name} |
| 53 | RUNTIME DESTINATION examples) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 54 | endmacro(add_llvm_example name) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 55 | |
| 56 | |
| 57 | macro(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 ) |
| 68 | endmacro(add_llvm_target) |