Skip lit tests if lit cannot be found

This commit is contained in:
Chris Kitching
2017-10-16 20:23:32 +01:00
parent 764d89dcbe
commit 9a3faec12c
+10 -3
View File
@@ -3,6 +3,13 @@ project(hipify-clang)
option(HIPIFY_CLANG_TESTS "Build the tests for hipify-clang, if lit is installed" ON) option(HIPIFY_CLANG_TESTS "Build the tests for hipify-clang, if lit is installed" ON)
# Disable the tests if `lit` is not installed.
find_program(LIT_COMMAND lit)
if (NOT LIT_COMMAND)
set(HIPIFY_CLANG_TESTS OFF CACHE INTERNAL "")
message(STATUS "hipify-clang's tests are not being built because `lit` is not installed.")
endif()
if (PARENT_SCOPE) if (PARENT_SCOPE)
set(BUILD_HIPIFY_CLANG 0 PARENT_SCOPE) set(BUILD_HIPIFY_CLANG 0 PARENT_SCOPE)
endif() endif()
@@ -67,20 +74,20 @@ install(TARGETS hipify-clang DESTINATION bin)
if (HIPIFY_CLANG_TESTS) if (HIPIFY_CLANG_TESTS)
# tests # tests
find_package(PythonInterp 2.7 REQUIRED EXACT) find_package(PythonInterp 2.7 REQUIRED EXACT)
find_program(LIT_COMMAND lit)
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
configure_file( configure_file(
${CMAKE_SOURCE_DIR}/tests/hipify-clang/lit.site.cfg.in ${CMAKE_SOURCE_DIR}/tests/hipify-clang/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/tests/hipify-clang/lit.site.cfg ${CMAKE_CURRENT_BINARY_DIR}/tests/hipify-clang/lit.site.cfg
@ONLY) @ONLY
)
add_lit_testsuite(test-hipify "Running HIPify regression tests" add_lit_testsuite(test-hipify "Running HIPify regression tests"
${CMAKE_SOURCE_DIR}/tests/hipify-clang ${CMAKE_SOURCE_DIR}/tests/hipify-clang
PARAMS site_config=${CMAKE_CURRENT_BINARY_DIR}/tests/hipify-clang/lit.site.cfg PARAMS site_config=${CMAKE_CURRENT_BINARY_DIR}/tests/hipify-clang/lit.site.cfg
DEPENDS hipify-clang lit DEPENDS hipify-clang lit
) )
add_custom_target(test-hipify-clang) add_custom_target(test-hipify-clang)
add_dependencies(test-hipify-clang test-hipify) add_dependencies(test-hipify-clang test-hipify)