From 7515386cf87fa625b4c9e0f157e8e6a2eb1b125f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 09:19:25 -0400 Subject: [PATCH] CMake: clean up test setup - Remove redundant searches for ECM and Qt::Test, move them to top-level. --- CMakeLists.txt | 5 ++++ src/modules/contextualprocess/CMakeLists.txt | 5 +--- src/modules/fsresizer/CMakeLists.txt | 5 +--- src/modules/locale/CMakeLists.txt | 6 ----- src/modules/partition/tests/CMakeLists.txt | 24 ++++++++++---------- src/modules/shellprocess/CMakeLists.txt | 5 +--- src/modules/users/CMakeLists.txt | 9 ++------ 7 files changed, 22 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f241cedd0..4fb88420b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,11 @@ set_package_properties( find_package(ECM ${ECM_VERSION} NO_MODULE) if( ECM_FOUND ) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) + if ( BUILD_TESTING ) + # ECM implies that we can build the tests, too + find_package( Qt5 COMPONENTS Test REQUIRED ) + include( ECMAddTests ) + endif() endif() find_package( KF5 COMPONENTS CoreAddons Crash ) diff --git a/src/modules/contextualprocess/CMakeLists.txt b/src/modules/contextualprocess/CMakeLists.txt index 2cf8d3879..f75946b58 100644 --- a/src/modules/contextualprocess/CMakeLists.txt +++ b/src/modules/contextualprocess/CMakeLists.txt @@ -8,10 +8,7 @@ calamares_add_plugin( contextualprocess SHARED_LIB ) -if( ECM_FOUND ) - find_package( Qt5 COMPONENTS Test REQUIRED ) - include( ECMAddTests ) - +if( ECM_FOUND AND BUILD_TESTING ) ecm_add_test( Tests.cpp ContextualProcessJob.cpp # Builds it a second time diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 5de329cad..e339b2799 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -20,10 +20,7 @@ if ( KPMcore_FOUND ) SHARED_LIB ) - if( ECM_FOUND ) - find_package( Qt5 COMPONENTS Test REQUIRED ) - include( ECMAddTests ) - + if( ECM_FOUND AND BUILD_TESTING ) ecm_add_test( Tests.cpp TEST_NAME diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 24259d797..576f2e16e 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -1,9 +1,3 @@ -find_package(ECM ${ECM_VERSION} NO_MODULE) -if( ECM_FOUND AND BUILD_TESTING ) - include( ECMAddTests ) - find_package( Qt5 COMPONENTS Core Test REQUIRED ) -endif() - # When debugging the timezone widget, add this debugging definition # to have a debugging-friendly timezone widget, debug logging, # and no intrusive timezone-setting while clicking around. diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index 68474287e..7b40c34a5 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -1,6 +1,4 @@ -find_package( Qt5 COMPONENTS Gui Test REQUIRED ) - -include( ECMAddTests ) +find_package( Qt5 COMPONENTS Gui REQUIRED ) set( PartitionModule_SOURCE_DIR .. ) @@ -23,13 +21,15 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) -ecm_add_test( ${partitionjobtests_SRCS} - TEST_NAME partitionjobtests - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - kpmcore - Qt5::Core - Qt5::Test -) +if( ECM_FOUND AND BUILD_TESTING ) + ecm_add_test( ${partitionjobtests_SRCS} + TEST_NAME partitionjobtests + LINK_LIBRARIES + ${CALAMARES_LIBRARIES} + kpmcore + Qt5::Core + Qt5::Test + ) -set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE ) + set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE ) +endif() diff --git a/src/modules/shellprocess/CMakeLists.txt b/src/modules/shellprocess/CMakeLists.txt index 51d4c4a4c..82ae8b911 100644 --- a/src/modules/shellprocess/CMakeLists.txt +++ b/src/modules/shellprocess/CMakeLists.txt @@ -8,10 +8,7 @@ calamares_add_plugin( shellprocess SHARED_LIB ) -if( ECM_FOUND ) - find_package( Qt5 COMPONENTS Test REQUIRED ) - include( ECMAddTests ) - +if( ECM_FOUND AND BUILD_TESTING ) ecm_add_test( Tests.cpp TEST_NAME diff --git a/src/modules/users/CMakeLists.txt b/src/modules/users/CMakeLists.txt index 16e235fd5..207ffbb3a 100644 --- a/src/modules/users/CMakeLists.txt +++ b/src/modules/users/CMakeLists.txt @@ -1,9 +1,4 @@ -find_package(ECM ${ECM_VERSION} NO_MODULE) -if( ECM_FOUND ) - include( ECMAddTests ) -endif() - -find_package( Qt5 COMPONENTS Core Test REQUIRED ) +find_package( Qt5 COMPONENTS Core REQUIRED ) find_package( Crypt REQUIRED ) # Add optional libraries here @@ -44,7 +39,7 @@ calamares_add_plugin( users SHARED_LIB ) -if( ECM_FOUND ) +if( ECM_FOUND AND BUILD_TESTING ) ecm_add_test( PasswordTests.cpp SetPasswordJob.cpp