blob: 33a3a2641a4849fdd3c9b363d38f794cb5bce7d1 [file] [log] [blame]
Chandler Carruth69ce6652012-06-30 10:14:14 +00001include(LLVMParseArguments)
Oscar Fuentes751ea9d2008-11-14 22:06:14 +00002include(LLVMProcessSources)
Oscar Fuentesd8a6dd62011-04-05 17:02:48 +00003include(LLVM-Config)
Oscar Fuentesa229b3c2008-09-22 01:08:49 +00004
5macro(add_llvm_library name)
Oscar Fuentes2c10b222008-11-15 02:08:08 +00006 llvm_process_sources( ALL_FILES ${ARGN} )
7 add_library( ${name} ${ALL_FILES} )
Oscar Fuentes5ed96262011-02-18 22:06:14 +00008 set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
Oscar Fuentes8807bdd2008-09-22 18:21:51 +00009 if( LLVM_COMMON_DEPENDS )
10 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
11 endif( LLVM_COMMON_DEPENDS )
Oscar Fuentesffe32e12010-10-14 15:54:41 +000012
13 if( BUILD_SHARED_LIBS )
Oscar Fuentescc48b9a2011-03-12 16:48:54 +000014 llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
NAKAMURA Takumicb065a62013-08-14 03:34:49 +000015 if (MSVC)
16 set_target_properties(${name}
17 PROPERTIES
18 IMPORT_SUFFIX ".imp")
19 endif ()
Oscar Fuentesffe32e12010-10-14 15:54:41 +000020 endif()
21
Oscar Fuentes978e5282011-03-29 20:51:08 +000022 # Ensure that the system libraries always comes last on the
23 # list. Without this, linking the unit tests on MinGW fails.
24 link_system_libs( ${name} )
25
Nick Lewycky61aed872011-04-29 02:12:06 +000026 if( EXCLUDE_FROM_ALL )
27 set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
28 else()
Hans Wennborg16546272013-08-24 00:20:36 +000029 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LTO")
30 install(TARGETS ${name}
31 LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
32 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
33 endif()
Nick Lewycky61aed872011-04-29 02:12:06 +000034 endif()
Oscar Fuentes3145e922011-02-20 22:06:10 +000035 set_target_properties(${name} PROPERTIES FOLDER "Libraries")
Daniel Dunbarfaaa76d2011-11-29 01:31:52 +000036
37 # Add the explicit dependency information for this library.
38 #
39 # It would be nice to verify that we have the dependencies for this library
40 # name, but using get_property(... SET) doesn't suffice to determine if a
41 # property has been set to an empty value.
42 get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
43 target_link_libraries(${name} ${lib_deps})
Oscar Fuentesa229b3c2008-09-22 01:08:49 +000044endmacro(add_llvm_library name)
45
Oscar Fuentesbbc10672009-11-10 02:45:37 +000046macro(add_llvm_loadable_module name)
Oscar Fuentesff11a232010-10-22 19:03:24 +000047 if( NOT LLVM_ON_UNIX OR CYGWIN )
Oscar Fuentesbbc10672009-11-10 02:45:37 +000048 message(STATUS "Loadable modules not supported on this platform.
49${name} ignored.")
NAKAMURA Takumia8c1c3f2010-12-10 02:15:36 +000050 # Add empty "phony" target
51 add_custom_target(${name})
Oscar Fuentesbbc10672009-11-10 02:45:37 +000052 else()
Oscar Fuentesbbc10672009-11-10 02:45:37 +000053 llvm_process_sources( ALL_FILES ${ARGN} )
Oscar Fuentes9f2b3842010-12-22 08:30:17 +000054 if (MODULE)
55 set(libkind MODULE)
56 else()
57 set(libkind SHARED)
58 endif()
59
60 add_library( ${name} ${libkind} ${ALL_FILES} )
Oscar Fuentesbbc10672009-11-10 02:45:37 +000061 set_target_properties( ${name} PROPERTIES PREFIX "" )
Douglas Gregor66df54f2009-11-10 15:30:33 +000062
Oscar Fuentescc48b9a2011-03-12 16:48:54 +000063 llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
Oscar Fuentes978e5282011-03-29 20:51:08 +000064 link_system_libs( ${name} )
Oscar Fuentescc48b9a2011-03-12 16:48:54 +000065
Douglas Gregor66df54f2009-11-10 15:30:33 +000066 if (APPLE)
67 # Darwin-specific linker flags for loadable modules.
68 set_target_properties(${name} PROPERTIES
69 LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
70 endif()
71
Oscar Fuentes638aaec2011-04-26 14:55:27 +000072 if( EXCLUDE_FROM_ALL )
Nick Lewycky61aed872011-04-29 02:12:06 +000073 set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
Oscar Fuentes638aaec2011-04-26 14:55:27 +000074 else()
Hans Wennborg16546272013-08-24 00:20:36 +000075 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
76 install(TARGETS ${name}
77 LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
78 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
79 endif()
Oscar Fuentes638aaec2011-04-26 14:55:27 +000080 endif()
Oscar Fuentesbbc10672009-11-10 02:45:37 +000081 endif()
Oscar Fuentes3145e922011-02-20 22:06:10 +000082
83 set_target_properties(${name} PROPERTIES FOLDER "Loadable modules")
Oscar Fuentesbbc10672009-11-10 02:45:37 +000084endmacro(add_llvm_loadable_module name)
85
86
Oscar Fuentesa229b3c2008-09-22 01:08:49 +000087macro(add_llvm_executable name)
Oscar Fuentes2c10b222008-11-15 02:08:08 +000088 llvm_process_sources( ALL_FILES ${ARGN} )
Oscar Fuentes0c2443a2009-11-23 00:21:43 +000089 if( EXCLUDE_FROM_ALL )
90 add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
91 else()
92 add_executable(${name} ${ALL_FILES})
93 endif()
94 set(EXCLUDE_FROM_ALL OFF)
Oscar Fuentes978e5282011-03-29 20:51:08 +000095 llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
Oscar Fuentes3fca0e82009-08-14 04:38:57 +000096 if( LLVM_COMMON_DEPENDS )
97 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
98 endif( LLVM_COMMON_DEPENDS )
Oscar Fuentes978e5282011-03-29 20:51:08 +000099 link_system_libs( ${name} )
Oscar Fuentesa229b3c2008-09-22 01:08:49 +0000100endmacro(add_llvm_executable name)
101
102
Hans Wennborg16546272013-08-24 00:20:36 +0000103set (LLVM_TOOLCHAIN_TOOLS
104 llvm-ar
105 llvm-objdump
106 )
107
Oscar Fuentesa229b3c2008-09-22 01:08:49 +0000108macro(add_llvm_tool name)
109 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
Oscar Fuentesdea579f2009-11-23 00:32:42 +0000110 if( NOT LLVM_BUILD_TOOLS )
Oscar Fuentes0c2443a2009-11-23 00:21:43 +0000111 set(EXCLUDE_FROM_ALL ON)
112 endif()
Oscar Fuentes46d8a932010-09-25 20:25:25 +0000113 add_llvm_executable(${name} ${ARGN})
Hans Wennborg16546272013-08-24 00:20:36 +0000114
115 list(FIND LLVM_TOOLCHAIN_TOOLS ${name} LLVM_IS_${name}_TOOLCHAIN_TOOL)
116 if (LLVM_IS_${name}_TOOLCHAIN_TOOL GREATER -1 OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
117 if( LLVM_BUILD_TOOLS )
118 install(TARGETS ${name} RUNTIME DESTINATION bin)
119 endif()
Oscar Fuentesdea579f2009-11-23 00:32:42 +0000120 endif()
Oscar Fuentes3145e922011-02-20 22:06:10 +0000121 set_target_properties(${name} PROPERTIES FOLDER "Tools")
Oscar Fuentesa229b3c2008-09-22 01:08:49 +0000122endmacro(add_llvm_tool name)
123
124
125macro(add_llvm_example name)
126# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR})
Oscar Fuentesdea579f2009-11-23 00:32:42 +0000127 if( NOT LLVM_BUILD_EXAMPLES )
Oscar Fuentes0c2443a2009-11-23 00:21:43 +0000128 set(EXCLUDE_FROM_ALL ON)
129 endif()
Oscar Fuentes46d8a932010-09-25 20:25:25 +0000130 add_llvm_executable(${name} ${ARGN})
Oscar Fuentesdea579f2009-11-23 00:32:42 +0000131 if( LLVM_BUILD_EXAMPLES )
132 install(TARGETS ${name} RUNTIME DESTINATION examples)
133 endif()
Oscar Fuentes3145e922011-02-20 22:06:10 +0000134 set_target_properties(${name} PROPERTIES FOLDER "Examples")
Oscar Fuentesa229b3c2008-09-22 01:08:49 +0000135endmacro(add_llvm_example name)
Oscar Fuentescdc95492008-09-26 04:40:32 +0000136
137
Oscar Fuentes3145e922011-02-20 22:06:10 +0000138macro(add_llvm_utility name)
139 add_llvm_executable(${name} ${ARGN})
140 set_target_properties(${name} PROPERTIES FOLDER "Utils")
141endmacro(add_llvm_utility name)
142
143
Oscar Fuentescdc95492008-09-26 04:40:32 +0000144macro(add_llvm_target target_name)
Oscar Fuentes4f0f3352011-07-25 20:17:01 +0000145 include_directories(BEFORE
146 ${CMAKE_CURRENT_BINARY_DIR}
147 ${CMAKE_CURRENT_SOURCE_DIR})
Douglas Gregor85fedbe2009-06-23 17:57:35 +0000148 add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT})
Oscar Fuentesba1186c2011-02-20 02:55:27 +0000149 set( CURRENT_LLVM_TARGET LLVM${target_name} )
Oscar Fuentescdc95492008-09-26 04:40:32 +0000150endmacro(add_llvm_target)
Michael J. Spencere734f542012-04-26 19:43:35 +0000151
152# Add external project that may want to be built as part of llvm such as Clang,
153# lld, and Polly. This adds two options. One for the source directory of the
154# project, which defaults to ${CMAKE_CURRENT_SOURCE_DIR}/${name}. Another to
155# enable or disable building it with everthing else.
NAKAMURA Takumi700cd402012-10-05 14:10:17 +0000156# Additional parameter can be specified as the name of directory.
Michael J. Spencere734f542012-04-26 19:43:35 +0000157macro(add_llvm_external_project name)
NAKAMURA Takumi700cd402012-10-05 14:10:17 +0000158 set(add_llvm_external_dir "${ARGN}")
159 if("${add_llvm_external_dir}" STREQUAL "")
160 set(add_llvm_external_dir ${name})
161 endif()
Argyrios Kyrtzidis7eec9d02013-08-21 19:13:44 +0000162 list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}")
NAKAMURA Takumi700cd402012-10-05 14:10:17 +0000163 string(REPLACE "-" "_" nameUNDERSCORE ${name})
164 string(TOUPPER ${nameUNDERSCORE} nameUPPER)
165 set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}"
Michael J. Spencere734f542012-04-26 19:43:35 +0000166 CACHE PATH "Path to ${name} source directory")
167 if (NOT ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} STREQUAL ""
168 AND EXISTS ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}/CMakeLists.txt)
169 option(LLVM_EXTERNAL_${nameUPPER}_BUILD
170 "Whether to build ${name} as part of LLVM" ON)
171 if (LLVM_EXTERNAL_${nameUPPER}_BUILD)
NAKAMURA Takumi700cd402012-10-05 14:10:17 +0000172 add_subdirectory(${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} ${add_llvm_external_dir})
Michael J. Spencere734f542012-04-26 19:43:35 +0000173 endif()
174 endif()
175endmacro(add_llvm_external_project)
Chandler Carrutha5d42f82012-06-21 05:16:58 +0000176
Argyrios Kyrtzidis7eec9d02013-08-21 19:13:44 +0000177macro(add_llvm_tool_subdirectory name)
178 list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${name}")
179 add_subdirectory(${name})
180endmacro(add_llvm_tool_subdirectory)
181
182macro(ignore_llvm_tool_subdirectory name)
183 list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${name}")
184endmacro(ignore_llvm_tool_subdirectory)
185
186function(add_llvm_implicit_external_projects)
187 set(list_of_implicit_subdirs "")
188 file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
189 foreach(dir ${sub-dirs})
190 if(IS_DIRECTORY "${dir}")
191 list(FIND LLVM_IMPLICIT_PROJECT_IGNORE "${dir}" tool_subdir_ignore)
192 if( tool_subdir_ignore EQUAL -1
193 AND EXISTS "${dir}/CMakeLists.txt")
194 get_filename_component(fn "${dir}" NAME)
195 list(APPEND list_of_implicit_subdirs "${fn}")
196 endif()
197 endif()
198 endforeach()
199
200 foreach(external_proj ${list_of_implicit_subdirs})
201 add_llvm_external_project("${external_proj}")
202 endforeach()
203endfunction(add_llvm_implicit_external_projects)
204
Chandler Carrutha5d42f82012-06-21 05:16:58 +0000205# Generic support for adding a unittest.
Chandler Carruth94d02512012-06-21 09:51:26 +0000206function(add_unittest test_suite test_name)
NAKAMURA Takumic42bdfc2013-01-27 12:46:53 +0000207 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
Chandler Carrutha5d42f82012-06-21 05:16:58 +0000208 if( NOT LLVM_BUILD_TESTS )
209 set(EXCLUDE_FROM_ALL ON)
210 endif()
211
212 add_llvm_executable(${test_name} ${ARGN})
213 target_link_libraries(${test_name}
214 gtest
215 gtest_main
216 LLVMSupport # gtest needs it for raw_ostream.
217 )
218
219 add_dependencies(${test_suite} ${test_name})
220 get_target_property(test_suite_folder ${test_suite} FOLDER)
221 if (NOT ${test_suite_folder} STREQUAL "NOTFOUND")
222 set_property(TARGET ${test_name} PROPERTY FOLDER "${test_suite_folder}")
223 endif ()
224
225 # Visual Studio 2012 only supports up to 8 template parameters in
226 # std::tr1::tuple by default, but gtest requires 10
227 if (MSVC AND MSVC_VERSION EQUAL 1700)
228 set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS _VARIADIC_MAX=10)
229 endif ()
230
231 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
232 set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
Chandler Carrutha5d42f82012-06-21 05:16:58 +0000233 if (NOT LLVM_ENABLE_THREADS)
234 set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
235 endif ()
236
Chandler Carruth582e8a52012-06-21 18:44:24 +0000237 get_property(target_compile_flags TARGET ${test_name} PROPERTY COMPILE_FLAGS)
238 if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
239 set(target_compile_flags "${target_compile_flags} -fno-rtti")
240 elseif (MSVC)
Aaron Ballmanbde2cd12013-08-06 23:34:04 +0000241 llvm_replace_compiler_option(target_compile_flags "/GR" "/GR-")
Chandler Carrutha5d42f82012-06-21 05:16:58 +0000242 endif ()
Chandler Carruth582e8a52012-06-21 18:44:24 +0000243
244 if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
245 set(target_compile_flags "${target_compile_flags} -Wno-variadic-macros")
246 endif ()
247 set_property(TARGET ${test_name} PROPERTY COMPILE_FLAGS "${target_compile_flags}")
Chandler Carrutha5d42f82012-06-21 05:16:58 +0000248endfunction()
Chandler Carruth3511dd32012-06-28 06:36:24 +0000249
250# This function provides an automatic way to 'configure'-like generate a file
251# based on a set of common and custom variables, specifically targetting the
252# variables needed for the 'lit.site.cfg' files. This function bundles the
253# common variables that any Lit instance is likely to need, and custom
254# variables can be passed in.
255function(configure_lit_site_cfg input output)
256 foreach(c ${LLVM_TARGETS_TO_BUILD})
257 set(TARGETS_BUILT "${TARGETS_BUILT} ${c}")
258 endforeach(c)
259 set(TARGETS_TO_BUILD ${TARGETS_BUILT})
260
261 set(SHLIBEXT "${LTDL_SHLIB_EXT}")
262 set(SHLIBDIR "${LLVM_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}")
263
264 if(BUILD_SHARED_LIBS)
265 set(LLVM_SHARED_LIBS_ENABLED "1")
266 else()
267 set(LLVM_SHARED_LIBS_ENABLED "0")
268 endif(BUILD_SHARED_LIBS)
269
270 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
271 set(SHLIBPATH_VAR "DYLD_LIBRARY_PATH")
272 else() # Default for all other unix like systems.
273 # CMake hardcodes the library locaction using rpath.
274 # Therefore LD_LIBRARY_PATH is not required to run binaries in the
275 # build dir. We pass it anyways.
276 set(SHLIBPATH_VAR "LD_LIBRARY_PATH")
277 endif()
278
279 # Configuration-time: See Unit/lit.site.cfg.in
NAKAMURA Takumi0dc10d52013-12-04 11:15:17 +0000280 if (CMAKE_CFG_INTDIR STREQUAL ".")
281 set(LLVM_BUILD_MODE ".")
282 else ()
283 set(LLVM_BUILD_MODE "%(build_mode)s")
284 endif ()
Chandler Carruth3511dd32012-06-28 06:36:24 +0000285
286 set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
287 set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
NAKAMURA Takumi0dc10d52013-12-04 11:15:17 +0000288 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/${LLVM_BUILD_MODE}")
289 set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/${LLVM_BUILD_MODE}")
Chandler Carruth3511dd32012-06-28 06:36:24 +0000290 set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
291 set(ENABLE_SHARED ${LLVM_SHARED_LIBS_ENABLED})
292 set(SHLIBPATH_VAR ${SHLIBPATH_VAR})
293
294 if(LLVM_ENABLE_ASSERTIONS AND NOT MSVC_IDE)
295 set(ENABLE_ASSERTIONS "1")
296 else()
297 set(ENABLE_ASSERTIONS "0")
298 endif()
299
Tim Northoverbfe84682013-02-14 16:49:32 +0000300 set(HOST_OS ${CMAKE_SYSTEM_NAME})
301 set(HOST_ARCH ${CMAKE_SYSTEM_PROCESSOR})
Chandler Carruth3511dd32012-06-28 06:36:24 +0000302
Roman Divackyc9871112013-08-27 19:25:01 +0000303 if (CLANG_ENABLE_ARCMT)
304 set(ENABLE_CLANG_ARCMT "1")
305 else()
306 set(ENABLE_CLANG_ARCMT "0")
307 endif()
308 if (CLANG_ENABLE_REWRITER)
309 set(ENABLE_CLANG_REWRITER "1")
310 else()
311 set(ENABLE_CLANG_REWRITER "0")
312 endif()
313 if (CLANG_ENABLE_STATIC_ANALYZER)
314 set(ENABLE_CLANG_STATIC_ANALYZER "1")
315 else()
316 set(ENABLE_CLANG_STATIC_ANALYZER "0")
317 endif()
318
Chandler Carruth3511dd32012-06-28 06:36:24 +0000319 configure_file(${input} ${output} @ONLY)
320endfunction()
Chandler Carruth69ce6652012-06-30 10:14:14 +0000321
322# A raw function to create a lit target. This is used to implement the testuite
323# management functions.
324function(add_lit_target target comment)
325 parse_arguments(ARG "PARAMS;DEPENDS;ARGS" "" ${ARGN})
326 set(LIT_ARGS "${ARG_ARGS} ${LLVM_LIT_ARGS}")
327 separate_arguments(LIT_ARGS)
NAKAMURA Takumi0dc10d52013-12-04 11:15:17 +0000328 if (NOT CMAKE_CFG_INTDIR STREQUAL ".")
329 list(APPEND LIT_ARGS --param build_mode=${CMAKE_CFG_INTDIR})
330 endif ()
Chandler Carruth69ce6652012-06-30 10:14:14 +0000331 set(LIT_COMMAND
332 ${PYTHON_EXECUTABLE}
Chandler Carruthcfa46522012-07-02 20:14:54 +0000333 ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py
Chandler Carruth69ce6652012-06-30 10:14:14 +0000334 ${LIT_ARGS}
335 )
336 foreach(param ${ARG_PARAMS})
337 list(APPEND LIT_COMMAND --param ${param})
338 endforeach()
NAKAMURA Takumi04a664e2012-12-24 22:43:59 +0000339 if( ARG_DEPENDS )
340 add_custom_target(${target}
341 COMMAND ${LIT_COMMAND} ${ARG_DEFAULT_ARGS}
342 COMMENT "${comment}"
343 )
344 add_dependencies(${target} ${ARG_DEPENDS})
345 else()
346 add_custom_target(${target}
347 COMMAND cmake -E echo "${target} does nothing, no tools built.")
348 message(STATUS "${target} does nothing.")
349 endif()
NAKAMURA Takumi03fc7302013-12-02 11:31:19 +0000350
351 # Tests should be excluded from "Build Solution".
352 set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
Chandler Carruth69ce6652012-06-30 10:14:14 +0000353endfunction()
354
355# A function to add a set of lit test suites to be driven through 'check-*' targets.
356function(add_lit_testsuite target comment)
357 parse_arguments(ARG "PARAMS;DEPENDS;ARGS" "" ${ARGN})
358
NAKAMURA Takumi54d22742012-10-10 13:32:55 +0000359 # EXCLUDE_FROM_ALL excludes the test ${target} out of check-all.
360 if(NOT EXCLUDE_FROM_ALL)
361 # Register the testsuites, params and depends for the global check rule.
362 set_property(GLOBAL APPEND PROPERTY LLVM_LIT_TESTSUITES ${ARG_DEFAULT_ARGS})
363 set_property(GLOBAL APPEND PROPERTY LLVM_LIT_PARAMS ${ARG_PARAMS})
364 set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS})
365 set_property(GLOBAL APPEND PROPERTY LLVM_LIT_EXTRA_ARGS ${ARG_ARGS})
366 endif()
Chandler Carruth69ce6652012-06-30 10:14:14 +0000367
368 # Produce a specific suffixed check rule.
369 add_lit_target(${target} ${comment}
370 ${ARG_DEFAULT_ARGS}
371 PARAMS ${ARG_PARAMS}
372 DEPENDS ${ARG_DEPENDS}
373 ARGS ${ARG_ARGS}
374 )
375endfunction()