Chandler Carruth | cf23bd3 | 2012-06-30 10:14:14 +0000 | [diff] [blame] | 1 | include(LLVMParseArguments) |
Oscar Fuentes | 1bbdd46 | 2008-11-14 22:06:14 +0000 | [diff] [blame] | 2 | include(LLVMProcessSources) |
Oscar Fuentes | e7510c2 | 2011-04-05 17:02:48 +0000 | [diff] [blame] | 3 | include(LLVM-Config) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 4 | |
| 5 | macro(add_llvm_library name) |
Oscar Fuentes | 50925fb | 2008-11-15 02:08:08 +0000 | [diff] [blame] | 6 | llvm_process_sources( ALL_FILES ${ARGN} ) |
| 7 | add_library( ${name} ${ALL_FILES} ) |
Oscar Fuentes | 6d857ca | 2011-02-18 22:06:14 +0000 | [diff] [blame] | 8 | set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} ) |
Oscar Fuentes | 1d8e4cf | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 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 ) |
Oscar Fuentes | 879d3a9 | 2011-03-12 16:48:54 +0000 | [diff] [blame] | 14 | llvm_config( ${name} ${LLVM_LINK_COMPONENTS} ) |
Oscar Fuentes | 00a9618 | 2010-10-14 15:54:41 +0000 | [diff] [blame] | 15 | endif() |
| 16 | |
Oscar Fuentes | 23f0bfe | 2011-03-29 20:51:08 +0000 | [diff] [blame] | 17 | # Ensure that the system libraries always comes last on the |
| 18 | # list. Without this, linking the unit tests on MinGW fails. |
| 19 | link_system_libs( ${name} ) |
| 20 | |
Nick Lewycky | bcffb1f | 2011-04-29 02:12:06 +0000 | [diff] [blame] | 21 | if( EXCLUDE_FROM_ALL ) |
| 22 | set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON) |
| 23 | else() |
| 24 | install(TARGETS ${name} |
| 25 | LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} |
| 26 | ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) |
| 27 | endif() |
Oscar Fuentes | 0b85d07 | 2011-02-20 22:06:10 +0000 | [diff] [blame] | 28 | set_target_properties(${name} PROPERTIES FOLDER "Libraries") |
Daniel Dunbar | 288bc5c | 2011-11-29 01:31:52 +0000 | [diff] [blame] | 29 | |
| 30 | # Add the explicit dependency information for this library. |
| 31 | # |
| 32 | # It would be nice to verify that we have the dependencies for this library |
| 33 | # name, but using get_property(... SET) doesn't suffice to determine if a |
| 34 | # property has been set to an empty value. |
| 35 | get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name}) |
| 36 | target_link_libraries(${name} ${lib_deps}) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 37 | endmacro(add_llvm_library name) |
| 38 | |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 39 | macro(add_llvm_loadable_module name) |
Oscar Fuentes | 01a575e | 2010-10-22 19:03:24 +0000 | [diff] [blame] | 40 | if( NOT LLVM_ON_UNIX OR CYGWIN ) |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 41 | message(STATUS "Loadable modules not supported on this platform. |
| 42 | ${name} ignored.") |
NAKAMURA Takumi | 51c06bf | 2010-12-10 02:15:36 +0000 | [diff] [blame] | 43 | # Add empty "phony" target |
| 44 | add_custom_target(${name}) |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 45 | else() |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 46 | llvm_process_sources( ALL_FILES ${ARGN} ) |
Oscar Fuentes | 7110428 | 2010-12-22 08:30:17 +0000 | [diff] [blame] | 47 | if (MODULE) |
| 48 | set(libkind MODULE) |
| 49 | else() |
| 50 | set(libkind SHARED) |
| 51 | endif() |
| 52 | |
| 53 | add_library( ${name} ${libkind} ${ALL_FILES} ) |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 54 | set_target_properties( ${name} PROPERTIES PREFIX "" ) |
Douglas Gregor | 8781416 | 2009-11-10 15:30:33 +0000 | [diff] [blame] | 55 | |
Oscar Fuentes | 879d3a9 | 2011-03-12 16:48:54 +0000 | [diff] [blame] | 56 | llvm_config( ${name} ${LLVM_LINK_COMPONENTS} ) |
Oscar Fuentes | 23f0bfe | 2011-03-29 20:51:08 +0000 | [diff] [blame] | 57 | link_system_libs( ${name} ) |
Oscar Fuentes | 879d3a9 | 2011-03-12 16:48:54 +0000 | [diff] [blame] | 58 | |
Douglas Gregor | 8781416 | 2009-11-10 15:30:33 +0000 | [diff] [blame] | 59 | if (APPLE) |
| 60 | # Darwin-specific linker flags for loadable modules. |
| 61 | set_target_properties(${name} PROPERTIES |
| 62 | LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress") |
| 63 | endif() |
| 64 | |
Oscar Fuentes | ab92d1e | 2011-04-26 14:55:27 +0000 | [diff] [blame] | 65 | if( EXCLUDE_FROM_ALL ) |
Nick Lewycky | bcffb1f | 2011-04-29 02:12:06 +0000 | [diff] [blame] | 66 | set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON) |
Oscar Fuentes | ab92d1e | 2011-04-26 14:55:27 +0000 | [diff] [blame] | 67 | else() |
| 68 | install(TARGETS ${name} |
Gabor Greif | 9ae2dfd | 2012-07-12 13:18:13 +0000 | [diff] [blame] | 69 | LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} |
| 70 | ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) |
Oscar Fuentes | ab92d1e | 2011-04-26 14:55:27 +0000 | [diff] [blame] | 71 | endif() |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 72 | endif() |
Oscar Fuentes | 0b85d07 | 2011-02-20 22:06:10 +0000 | [diff] [blame] | 73 | |
| 74 | set_target_properties(${name} PROPERTIES FOLDER "Loadable modules") |
Oscar Fuentes | c5e1ae1 | 2009-11-10 02:45:37 +0000 | [diff] [blame] | 75 | endmacro(add_llvm_loadable_module name) |
| 76 | |
| 77 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 78 | macro(add_llvm_executable name) |
Oscar Fuentes | 50925fb | 2008-11-15 02:08:08 +0000 | [diff] [blame] | 79 | llvm_process_sources( ALL_FILES ${ARGN} ) |
Oscar Fuentes | b8352de | 2009-11-23 00:21:43 +0000 | [diff] [blame] | 80 | if( EXCLUDE_FROM_ALL ) |
| 81 | add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES}) |
| 82 | else() |
| 83 | add_executable(${name} ${ALL_FILES}) |
| 84 | endif() |
| 85 | set(EXCLUDE_FROM_ALL OFF) |
Oscar Fuentes | 23f0bfe | 2011-03-29 20:51:08 +0000 | [diff] [blame] | 86 | llvm_config( ${name} ${LLVM_LINK_COMPONENTS} ) |
Oscar Fuentes | d8b1b9a | 2009-08-14 04:38:57 +0000 | [diff] [blame] | 87 | if( LLVM_COMMON_DEPENDS ) |
| 88 | add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) |
| 89 | endif( LLVM_COMMON_DEPENDS ) |
Oscar Fuentes | 23f0bfe | 2011-03-29 20:51:08 +0000 | [diff] [blame] | 90 | link_system_libs( ${name} ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 91 | endmacro(add_llvm_executable name) |
| 92 | |
| 93 | |
| 94 | macro(add_llvm_tool name) |
| 95 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) |
Oscar Fuentes | 7be498e | 2009-11-23 00:32:42 +0000 | [diff] [blame] | 96 | if( NOT LLVM_BUILD_TOOLS ) |
Oscar Fuentes | b8352de | 2009-11-23 00:21:43 +0000 | [diff] [blame] | 97 | set(EXCLUDE_FROM_ALL ON) |
| 98 | endif() |
Oscar Fuentes | 066de85 | 2010-09-25 20:25:25 +0000 | [diff] [blame] | 99 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 7be498e | 2009-11-23 00:32:42 +0000 | [diff] [blame] | 100 | if( LLVM_BUILD_TOOLS ) |
| 101 | install(TARGETS ${name} RUNTIME DESTINATION bin) |
| 102 | endif() |
Oscar Fuentes | 0b85d07 | 2011-02-20 22:06:10 +0000 | [diff] [blame] | 103 | set_target_properties(${name} PROPERTIES FOLDER "Tools") |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 104 | endmacro(add_llvm_tool name) |
| 105 | |
| 106 | |
| 107 | macro(add_llvm_example name) |
| 108 | # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR}) |
Oscar Fuentes | 7be498e | 2009-11-23 00:32:42 +0000 | [diff] [blame] | 109 | if( NOT LLVM_BUILD_EXAMPLES ) |
Oscar Fuentes | b8352de | 2009-11-23 00:21:43 +0000 | [diff] [blame] | 110 | set(EXCLUDE_FROM_ALL ON) |
| 111 | endif() |
Oscar Fuentes | 066de85 | 2010-09-25 20:25:25 +0000 | [diff] [blame] | 112 | add_llvm_executable(${name} ${ARGN}) |
Oscar Fuentes | 7be498e | 2009-11-23 00:32:42 +0000 | [diff] [blame] | 113 | if( LLVM_BUILD_EXAMPLES ) |
| 114 | install(TARGETS ${name} RUNTIME DESTINATION examples) |
| 115 | endif() |
Oscar Fuentes | 0b85d07 | 2011-02-20 22:06:10 +0000 | [diff] [blame] | 116 | set_target_properties(${name} PROPERTIES FOLDER "Examples") |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 117 | endmacro(add_llvm_example name) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 118 | |
| 119 | |
Oscar Fuentes | 0b85d07 | 2011-02-20 22:06:10 +0000 | [diff] [blame] | 120 | macro(add_llvm_utility name) |
| 121 | add_llvm_executable(${name} ${ARGN}) |
| 122 | set_target_properties(${name} PROPERTIES FOLDER "Utils") |
| 123 | endmacro(add_llvm_utility name) |
| 124 | |
| 125 | |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 126 | macro(add_llvm_target target_name) |
Oscar Fuentes | d7808d2 | 2011-07-25 20:17:01 +0000 | [diff] [blame] | 127 | include_directories(BEFORE |
| 128 | ${CMAKE_CURRENT_BINARY_DIR} |
| 129 | ${CMAKE_CURRENT_SOURCE_DIR}) |
Douglas Gregor | 7e9e36a | 2009-06-23 17:57:35 +0000 | [diff] [blame] | 130 | add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT}) |
Oscar Fuentes | 00d78f1 | 2011-02-20 02:55:27 +0000 | [diff] [blame] | 131 | set( CURRENT_LLVM_TARGET LLVM${target_name} ) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 132 | endmacro(add_llvm_target) |
Michael J. Spencer | 3c00db7 | 2012-04-26 19:43:35 +0000 | [diff] [blame] | 133 | |
| 134 | # Add external project that may want to be built as part of llvm such as Clang, |
| 135 | # lld, and Polly. This adds two options. One for the source directory of the |
| 136 | # project, which defaults to ${CMAKE_CURRENT_SOURCE_DIR}/${name}. Another to |
| 137 | # enable or disable building it with everthing else. |
| 138 | macro(add_llvm_external_project name) |
| 139 | string(TOUPPER ${name} nameUPPER) |
| 140 | set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${name}" |
| 141 | CACHE PATH "Path to ${name} source directory") |
| 142 | if (NOT ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} STREQUAL "" |
| 143 | AND EXISTS ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}/CMakeLists.txt) |
| 144 | option(LLVM_EXTERNAL_${nameUPPER}_BUILD |
| 145 | "Whether to build ${name} as part of LLVM" ON) |
| 146 | if (LLVM_EXTERNAL_${nameUPPER}_BUILD) |
| 147 | add_subdirectory(${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} ${name}) |
| 148 | endif() |
| 149 | endif() |
| 150 | endmacro(add_llvm_external_project) |
Chandler Carruth | b60182e | 2012-06-21 05:16:58 +0000 | [diff] [blame] | 151 | |
| 152 | # Generic support for adding a unittest. |
Chandler Carruth | 7c888ee | 2012-06-21 09:51:26 +0000 | [diff] [blame] | 153 | function(add_unittest test_suite test_name) |
Chandler Carruth | b60182e | 2012-06-21 05:16:58 +0000 | [diff] [blame] | 154 | if (CMAKE_BUILD_TYPE) |
| 155 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY |
Chandler Carruth | 7c888ee | 2012-06-21 09:51:26 +0000 | [diff] [blame] | 156 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}) |
Chandler Carruth | b60182e | 2012-06-21 05:16:58 +0000 | [diff] [blame] | 157 | else() |
Chandler Carruth | 7c888ee | 2012-06-21 09:51:26 +0000 | [diff] [blame] | 158 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
Chandler Carruth | b60182e | 2012-06-21 05:16:58 +0000 | [diff] [blame] | 159 | endif() |
| 160 | if( NOT LLVM_BUILD_TESTS ) |
| 161 | set(EXCLUDE_FROM_ALL ON) |
| 162 | endif() |
| 163 | |
| 164 | add_llvm_executable(${test_name} ${ARGN}) |
| 165 | target_link_libraries(${test_name} |
| 166 | gtest |
| 167 | gtest_main |
| 168 | LLVMSupport # gtest needs it for raw_ostream. |
| 169 | ) |
| 170 | |
| 171 | add_dependencies(${test_suite} ${test_name}) |
| 172 | get_target_property(test_suite_folder ${test_suite} FOLDER) |
| 173 | if (NOT ${test_suite_folder} STREQUAL "NOTFOUND") |
| 174 | set_property(TARGET ${test_name} PROPERTY FOLDER "${test_suite_folder}") |
| 175 | endif () |
| 176 | |
| 177 | # Visual Studio 2012 only supports up to 8 template parameters in |
| 178 | # std::tr1::tuple by default, but gtest requires 10 |
| 179 | if (MSVC AND MSVC_VERSION EQUAL 1700) |
| 180 | set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS _VARIADIC_MAX=10) |
| 181 | endif () |
| 182 | |
| 183 | include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) |
| 184 | set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_RTTI=0) |
Chandler Carruth | b60182e | 2012-06-21 05:16:58 +0000 | [diff] [blame] | 185 | if (NOT LLVM_ENABLE_THREADS) |
| 186 | set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0) |
| 187 | endif () |
| 188 | |
Chandler Carruth | 343c32a | 2012-06-21 18:44:24 +0000 | [diff] [blame] | 189 | get_property(target_compile_flags TARGET ${test_name} PROPERTY COMPILE_FLAGS) |
| 190 | if (LLVM_COMPILER_IS_GCC_COMPATIBLE) |
| 191 | set(target_compile_flags "${target_compile_flags} -fno-rtti") |
| 192 | elseif (MSVC) |
| 193 | set(target_compile_flags "${target_compile_flags} /GR-") |
Chandler Carruth | b60182e | 2012-06-21 05:16:58 +0000 | [diff] [blame] | 194 | endif () |
Chandler Carruth | 343c32a | 2012-06-21 18:44:24 +0000 | [diff] [blame] | 195 | |
| 196 | if (SUPPORTS_NO_VARIADIC_MACROS_FLAG) |
| 197 | set(target_compile_flags "${target_compile_flags} -Wno-variadic-macros") |
| 198 | endif () |
| 199 | set_property(TARGET ${test_name} PROPERTY COMPILE_FLAGS "${target_compile_flags}") |
Chandler Carruth | b60182e | 2012-06-21 05:16:58 +0000 | [diff] [blame] | 200 | endfunction() |
Chandler Carruth | c502ed6 | 2012-06-28 06:36:24 +0000 | [diff] [blame] | 201 | |
| 202 | # This function provides an automatic way to 'configure'-like generate a file |
| 203 | # based on a set of common and custom variables, specifically targetting the |
| 204 | # variables needed for the 'lit.site.cfg' files. This function bundles the |
| 205 | # common variables that any Lit instance is likely to need, and custom |
| 206 | # variables can be passed in. |
| 207 | function(configure_lit_site_cfg input output) |
| 208 | foreach(c ${LLVM_TARGETS_TO_BUILD}) |
| 209 | set(TARGETS_BUILT "${TARGETS_BUILT} ${c}") |
| 210 | endforeach(c) |
| 211 | set(TARGETS_TO_BUILD ${TARGETS_BUILT}) |
| 212 | |
| 213 | set(SHLIBEXT "${LTDL_SHLIB_EXT}") |
| 214 | set(SHLIBDIR "${LLVM_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}") |
| 215 | |
| 216 | if(BUILD_SHARED_LIBS) |
| 217 | set(LLVM_SHARED_LIBS_ENABLED "1") |
| 218 | else() |
| 219 | set(LLVM_SHARED_LIBS_ENABLED "0") |
| 220 | endif(BUILD_SHARED_LIBS) |
| 221 | |
| 222 | if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
| 223 | set(SHLIBPATH_VAR "DYLD_LIBRARY_PATH") |
| 224 | else() # Default for all other unix like systems. |
| 225 | # CMake hardcodes the library locaction using rpath. |
| 226 | # Therefore LD_LIBRARY_PATH is not required to run binaries in the |
| 227 | # build dir. We pass it anyways. |
| 228 | set(SHLIBPATH_VAR "LD_LIBRARY_PATH") |
| 229 | endif() |
| 230 | |
| 231 | # Configuration-time: See Unit/lit.site.cfg.in |
| 232 | set(LLVM_BUILD_MODE "%(build_mode)s") |
| 233 | |
| 234 | set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR}) |
| 235 | set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR}) |
| 236 | set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s") |
Chandler Carruth | 2178d73 | 2012-06-29 00:40:15 +0000 | [diff] [blame] | 237 | set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_config)s") |
Chandler Carruth | c502ed6 | 2012-06-28 06:36:24 +0000 | [diff] [blame] | 238 | set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) |
| 239 | set(ENABLE_SHARED ${LLVM_SHARED_LIBS_ENABLED}) |
| 240 | set(SHLIBPATH_VAR ${SHLIBPATH_VAR}) |
| 241 | |
| 242 | if(LLVM_ENABLE_ASSERTIONS AND NOT MSVC_IDE) |
| 243 | set(ENABLE_ASSERTIONS "1") |
| 244 | else() |
| 245 | set(ENABLE_ASSERTIONS "0") |
| 246 | endif() |
| 247 | |
| 248 | set(HOST_OS ${CMAKE_HOST_SYSTEM_NAME}) |
| 249 | set(HOST_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR}) |
| 250 | |
| 251 | configure_file(${input} ${output} @ONLY) |
| 252 | endfunction() |
Chandler Carruth | cf23bd3 | 2012-06-30 10:14:14 +0000 | [diff] [blame] | 253 | |
| 254 | # A raw function to create a lit target. This is used to implement the testuite |
| 255 | # management functions. |
| 256 | function(add_lit_target target comment) |
| 257 | parse_arguments(ARG "PARAMS;DEPENDS;ARGS" "" ${ARGN}) |
| 258 | set(LIT_ARGS "${ARG_ARGS} ${LLVM_LIT_ARGS}") |
| 259 | separate_arguments(LIT_ARGS) |
| 260 | set(LIT_COMMAND |
| 261 | ${PYTHON_EXECUTABLE} |
Chandler Carruth | 20d8c16 | 2012-07-02 20:14:54 +0000 | [diff] [blame] | 262 | ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py |
Chandler Carruth | cf23bd3 | 2012-06-30 10:14:14 +0000 | [diff] [blame] | 263 | --param build_config=${CMAKE_CFG_INTDIR} |
| 264 | --param build_mode=${RUNTIME_BUILD_MODE} |
| 265 | ${LIT_ARGS} |
| 266 | ) |
| 267 | foreach(param ${ARG_PARAMS}) |
| 268 | list(APPEND LIT_COMMAND --param ${param}) |
| 269 | endforeach() |
| 270 | add_custom_target(${target} |
| 271 | COMMAND ${LIT_COMMAND} ${ARG_DEFAULT_ARGS} |
| 272 | COMMENT "${comment}" |
Chandler Carruth | cf23bd3 | 2012-06-30 10:14:14 +0000 | [diff] [blame] | 273 | ) |
Chandler Carruth | 33219d4 | 2012-07-02 21:31:03 +0000 | [diff] [blame] | 274 | |
| 275 | # It would be nice to use the DEPENDS clause in add_custom_target above, but |
| 276 | # that has bugs with the CMake 2.8.0 installed on Ubuntu Lucid when the entry |
| 277 | # in the depends is another custom target. Instead we add them through an |
| 278 | # explicit add_dependencies. |
| 279 | add_dependencies(${target} ${ARG_DEPENDS}) |
Chandler Carruth | cf23bd3 | 2012-06-30 10:14:14 +0000 | [diff] [blame] | 280 | endfunction() |
| 281 | |
| 282 | # A function to add a set of lit test suites to be driven through 'check-*' targets. |
| 283 | function(add_lit_testsuite target comment) |
| 284 | parse_arguments(ARG "PARAMS;DEPENDS;ARGS" "" ${ARGN}) |
| 285 | |
| 286 | # Register the testsuites, params and depends for the global check rule. |
| 287 | set_property(GLOBAL APPEND PROPERTY LLVM_LIT_TESTSUITES ${ARG_DEFAULT_ARGS}) |
| 288 | set_property(GLOBAL APPEND PROPERTY LLVM_LIT_PARAMS ${ARG_PARAMS}) |
| 289 | set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS}) |
| 290 | set_property(GLOBAL APPEND PROPERTY LLVM_LIT_EXTRA_ARGS ${ARG_ARGS}) |
| 291 | |
| 292 | # Produce a specific suffixed check rule. |
| 293 | add_lit_target(${target} ${comment} |
| 294 | ${ARG_DEFAULT_ARGS} |
| 295 | PARAMS ${ARG_PARAMS} |
| 296 | DEPENDS ${ARG_DEPENDS} |
| 297 | ARGS ${ARG_ARGS} |
| 298 | ) |
| 299 | endfunction() |