From 415232f18a08f5808bcf1582b374e0b7591c0c32 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 19 Dec 2016 12:44:26 +0000 Subject: [CMake] Only add dependencies to `check` if the target is enabled. Surprisingly the old code still worked even when the target didn't exist. --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d392f18..11c7e81b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -699,10 +699,16 @@ if ((NOT LIT_TOOL) OR (NOT EXISTS "${LIT_TOOL}")) message(STATUS "Using lit: ${LIT_TOOL}") endif() + # Add global test target + add_custom_target(check + COMMENT "Running tests" + ) + option(ENABLE_UNIT_TESTS "Enable unit tests" ON) if (ENABLE_UNIT_TESTS) message(STATUS "Unit tests enabled") add_subdirectory(unittests) + add_dependencies(check unittests) else() message(STATUS "Unit tests disabled") endif() @@ -710,15 +716,11 @@ if ((NOT LIT_TOOL) OR (NOT EXISTS "${LIT_TOOL}")) if (ENABLE_SYSTEM_TESTS) message(STATUS "System tests enabled") add_subdirectory(test) + add_dependencies(check systemtests) else() message(STATUS "System tests disabled") endif() - # Add global test target - add_custom_target(check - DEPENDS unittests systemtests - COMMENT "Running tests" - ) else() message(STATUS "Testing disabled") endif() -- cgit 1.4.1