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 | 1bbdd46 | 2008-11-14 22:06:14 +0000 | [diff] [blame] | 5 | llvm_process_sources( ${ARGN} ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 6 | add_library( ${name} ${ARGN} ) |
| 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 | 1bbdd46 | 2008-11-14 22:06:14 +0000 | [diff] [blame] | 19 | llvm_process_sources( ${ARGN} ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 20 | add_executable(${name} ${ARGN}) |
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 | 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 ) |
| 39 | endmacro(add_llvm_executable name) |
| 40 | |
| 41 | |
| 42 | macro(add_llvm_tool name) |
| 43 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) |
| 44 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 45 | install(TARGETS ${name} |
| 46 | RUNTIME DESTINATION bin) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 47 | endmacro(add_llvm_tool name) |
| 48 | |
| 49 | |
| 50 | macro(add_llvm_example name) |
| 51 | # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR}) |
| 52 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 53 | install(TARGETS ${name} |
| 54 | RUNTIME DESTINATION examples) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 55 | endmacro(add_llvm_example name) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 56 | |
| 57 | |
| 58 | macro(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 ) |
| 69 | endmacro(add_llvm_target) |