Oscar Fuentes | 1bbdd46 | 2008-11-14 22:06:14 +0000 | [diff] [blame] | 1 | include(LLVMProcessSources) |
Michael J. Spencer | 3a210e2 | 2010-09-13 23:59:48 +0000 | [diff] [blame] | 2 | include(LLVMConfig) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 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 | 00a9618 | 2010-10-14 15:54:41 +0000 | [diff] [blame] | 12 | |
| 13 | if( BUILD_SHARED_LIBS ) |
| 14 | get_system_libs(sl) |
| 15 | target_link_libraries( ${name} ${sl} ) |
| 16 | endif() |
| 17 | |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 18 | install(TARGETS ${name} |
Oscar Fuentes | af0f65f | 2009-06-12 02:49:53 +0000 | [diff] [blame] | 19 | LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} |
| 20 | ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) |
Oscar Fuentes | b78829e | 2009-08-16 05:16:43 +0000 | [diff] [blame] | 21 | # The LLVM Target library shall be built before its sublibraries |
| 22 | # (asmprinter, etc) because those may use tablegenned files which |
| 23 | # generation is triggered by the main LLVM target library. Necessary |
| 24 | # for parallel builds: |
| 25 | if( CURRENT_LLVM_TARGET ) |
Benjamin Kramer | 0bbbf7e | 2009-08-16 09:44:27 +0000 | [diff] [blame] | 26 | add_dependencies(${name} ${CURRENT_LLVM_TARGET}) |
Oscar Fuentes | b78829e | 2009-08-16 05:16:43 +0000 | [diff] [blame] | 27 | endif() |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 28 | endmacro(add_llvm_library name) |
| 29 | |
| 30 | |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 31 | macro(add_llvm_loadable_module name) |
Oscar Fuentes | 01a575e | 2010-10-22 19:03:24 +0000 | [diff] [blame] | 32 | if( NOT LLVM_ON_UNIX OR CYGWIN ) |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 33 | message(STATUS "Loadable modules not supported on this platform. |
| 34 | ${name} ignored.") |
| 35 | else() |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 36 | llvm_process_sources( ALL_FILES ${ARGN} ) |
| 37 | add_library( ${name} MODULE ${ALL_FILES} ) |
| 38 | set_target_properties( ${name} PROPERTIES PREFIX "" ) |
Douglas Gregor | 8781416 | 2009-11-10 15:30:33 +0000 | [diff] [blame] | 39 | |
| 40 | if (APPLE) |
| 41 | # Darwin-specific linker flags for loadable modules. |
| 42 | set_target_properties(${name} PROPERTIES |
| 43 | LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress") |
| 44 | endif() |
| 45 | |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 46 | install(TARGETS ${name} |
| 47 | LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} |
| 48 | ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) |
| 49 | endif() |
| 50 | endmacro(add_llvm_loadable_module name) |
| 51 | |
| 52 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 53 | macro(add_llvm_executable name) |
Oscar Fuentes | 50925fb | 2008-11-15 02:08:08 +0000 | [diff] [blame] | 54 | llvm_process_sources( ALL_FILES ${ARGN} ) |
Oscar Fuentes | b8352de | 2009-11-23 00:21:43 +0000 | [diff] [blame] | 55 | if( EXCLUDE_FROM_ALL ) |
| 56 | add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES}) |
| 57 | else() |
| 58 | add_executable(${name} ${ALL_FILES}) |
| 59 | endif() |
| 60 | set(EXCLUDE_FROM_ALL OFF) |
Oscar Fuentes | bcc1db5 | 2008-10-26 00:51:05 +0000 | [diff] [blame] | 61 | if( LLVM_USED_LIBS ) |
| 62 | foreach(lib ${LLVM_USED_LIBS}) |
| 63 | target_link_libraries( ${name} ${lib} ) |
| 64 | endforeach(lib) |
| 65 | endif( LLVM_USED_LIBS ) |
Michael J. Spencer | 3a210e2 | 2010-09-13 23:59:48 +0000 | [diff] [blame] | 66 | if( LLVM_LINK_COMPONENTS ) |
| 67 | llvm_config(${name} ${LLVM_LINK_COMPONENTS}) |
| 68 | endif( LLVM_LINK_COMPONENTS ) |
Oscar Fuentes | d8b1b9a | 2009-08-14 04:38:57 +0000 | [diff] [blame] | 69 | if( LLVM_COMMON_DEPENDS ) |
| 70 | add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) |
| 71 | endif( LLVM_COMMON_DEPENDS ) |
Michael J. Spencer | 1c4e934 | 2010-09-11 02:13:39 +0000 | [diff] [blame] | 72 | if( NOT MINGW ) |
| 73 | get_system_libs(llvm_system_libs) |
| 74 | if( llvm_system_libs ) |
| 75 | target_link_libraries(${name} ${llvm_system_libs}) |
| 76 | endif() |
| 77 | endif() |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 78 | endmacro(add_llvm_executable name) |
| 79 | |
| 80 | |
| 81 | macro(add_llvm_tool name) |
| 82 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) |
Oscar Fuentes | 7be498e | 2009-11-23 00:32:42 +0000 | [diff] [blame] | 83 | if( NOT LLVM_BUILD_TOOLS ) |
Oscar Fuentes | b8352de | 2009-11-23 00:21:43 +0000 | [diff] [blame] | 84 | set(EXCLUDE_FROM_ALL ON) |
| 85 | endif() |
Oscar Fuentes | 066de85 | 2010-09-25 20:25:25 +0000 | [diff] [blame] | 86 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 7be498e | 2009-11-23 00:32:42 +0000 | [diff] [blame] | 87 | if( LLVM_BUILD_TOOLS ) |
| 88 | install(TARGETS ${name} RUNTIME DESTINATION bin) |
| 89 | endif() |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 90 | endmacro(add_llvm_tool name) |
| 91 | |
| 92 | |
| 93 | macro(add_llvm_example name) |
| 94 | # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR}) |
Oscar Fuentes | 7be498e | 2009-11-23 00:32:42 +0000 | [diff] [blame] | 95 | if( NOT LLVM_BUILD_EXAMPLES ) |
Oscar Fuentes | b8352de | 2009-11-23 00:21:43 +0000 | [diff] [blame] | 96 | set(EXCLUDE_FROM_ALL ON) |
| 97 | endif() |
Oscar Fuentes | 066de85 | 2010-09-25 20:25:25 +0000 | [diff] [blame] | 98 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 7be498e | 2009-11-23 00:32:42 +0000 | [diff] [blame] | 99 | if( LLVM_BUILD_EXAMPLES ) |
| 100 | install(TARGETS ${name} RUNTIME DESTINATION examples) |
| 101 | endif() |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 102 | endmacro(add_llvm_example name) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 103 | |
| 104 | |
| 105 | macro(add_llvm_target target_name) |
| 106 | if( TABLEGEN_OUTPUT ) |
| 107 | add_custom_target(${target_name}Table_gen |
| 108 | DEPENDS ${TABLEGEN_OUTPUT}) |
| 109 | add_dependencies(${target_name}Table_gen ${LLVM_COMMON_DEPENDS}) |
| 110 | endif( TABLEGEN_OUTPUT ) |
| 111 | include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) |
Douglas Gregor | 7e9e36a | 2009-06-23 17:57:35 +0000 | [diff] [blame] | 112 | add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT}) |
Douglas Gregor | 343beeb | 2009-06-23 21:05:21 +0000 | [diff] [blame] | 113 | if ( TABLEGEN_OUTPUT ) |
| 114 | add_dependencies(LLVM${target_name} ${target_name}Table_gen) |
| 115 | endif (TABLEGEN_OUTPUT) |
Oscar Fuentes | 69e973d | 2009-08-16 07:44:02 +0000 | [diff] [blame] | 116 | set(CURRENT_LLVM_TARGET LLVM${target_name} PARENT_SCOPE) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 117 | endmacro(add_llvm_target) |