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} |
Oscar Fuentes | af0f65f | 2009-06-12 02:49:53 +0000 | [diff] [blame] | 13 | LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} |
| 14 | ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) |
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 ) |
Douglas Gregor | 8756a8d | 2009-06-23 18:30:17 +0000 | [diff] [blame] | 29 | target_link_libraries(${name} ${llvm_libs}) |
Oscar Fuentes | 1a53cbf | 2009-05-27 15:49:33 +0000 | [diff] [blame] | 30 | get_system_libs(llvm_system_libs) |
| 31 | if( llvm_system_libs ) |
| 32 | target_link_libraries(${name} ${llvm_system_libs}) |
| 33 | endif() |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 34 | endmacro(add_llvm_executable name) |
| 35 | |
| 36 | |
| 37 | macro(add_llvm_tool name) |
| 38 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) |
| 39 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 40 | install(TARGETS ${name} |
| 41 | RUNTIME DESTINATION bin) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 42 | endmacro(add_llvm_tool name) |
| 43 | |
| 44 | |
| 45 | macro(add_llvm_example name) |
| 46 | # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR}) |
| 47 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 48 | install(TARGETS ${name} |
| 49 | RUNTIME DESTINATION examples) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 50 | endmacro(add_llvm_example name) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 51 | |
| 52 | |
| 53 | macro(add_llvm_target target_name) |
| 54 | if( TABLEGEN_OUTPUT ) |
| 55 | add_custom_target(${target_name}Table_gen |
| 56 | DEPENDS ${TABLEGEN_OUTPUT}) |
| 57 | add_dependencies(${target_name}Table_gen ${LLVM_COMMON_DEPENDS}) |
| 58 | endif( TABLEGEN_OUTPUT ) |
| 59 | include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) |
Douglas Gregor | 7e9e36a | 2009-06-23 17:57:35 +0000 | [diff] [blame] | 60 | add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT}) |
Douglas Gregor | 343beeb | 2009-06-23 21:05:21 +0000 | [diff] [blame] | 61 | if ( TABLEGEN_OUTPUT ) |
| 62 | add_dependencies(LLVM${target_name} ${target_name}Table_gen) |
| 63 | endif (TABLEGEN_OUTPUT) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 64 | endmacro(add_llvm_target) |