Teach the CMake build system to run lit's test suite. These can be run
[oota-llvm.git] / utils / lit / CMakeLists.txt
1 # The configured file is not placed in the correct location
2 # until the tests are run as we need to copy it into
3 # a copy of the tests folder
4 configure_file("tests/lit.site.cfg.in" "lit.site.cfg" @ONLY)
5
6 # Lit's test suite creates output files next to the sources which makes the
7 # source tree dirty. This is undesirable because we do out of source builds.
8 # To work around this the tests and the configuration file are copied into the
9 # build directory just before running them. The tests are not copied over at
10 # configure time (i.e. ``file(COPY ...)``) because this could lead to stale
11 # tests being run.
12 add_custom_target(prepare-check-lit
13   COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/tests" "${CMAKE_CURRENT_BINARY_DIR}/tests"
14   COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg" "${CMAKE_CURRENT_BINARY_DIR}/tests"
15   COMMENT "Preparing lit tests"
16 )
17
18 # Add rules for lit's own test suite
19 add_lit_testsuite(check-lit "Running lit's tests"
20   ${CMAKE_CURRENT_BINARY_DIR}
21   DEPENDS "FileCheck" "not" "prepare-check-lit"
22 )
23
24 # For IDEs
25 set_target_properties(check-lit PROPERTIES FOLDER "Tests")
26 set_target_properties(prepare-check-lit PROPERTIES FOLDER "Tests")