blob: 44af299f13ce67024e6ca6fbd4f29499a1a2d623 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
From fe096c5d05c95bfdcfae6a5976e242e324f4152d Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Date: Fri, 5 Feb 2021 06:17:42 +0000
Subject: [PATCH] Use include(CTest) and BUILD_TESTING to make tests optional
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
CMakeLists.txt | 29 ++++++++++++++++++++---------
src/CMakeLists.txt | 2 +-
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92d50265..ee476ac5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -211,8 +211,15 @@ endif()
set(CFG_QMLSRCDIR "${kid3_SOURCE_DIR}/src/qml")
find_package(Threads)
-set(Python_ADDITIONAL_VERSIONS 3)
-find_package(PythonInterp REQUIRED)
+include(CTest)
+if(CMAKE_VERSION VERSION_LESS 3.12.0)
+ set(Python_ADDITIONAL_VERSIONS 3)
+ find_package(PythonInterp REQUIRED)
+ # PythonInterp sets PYTHON_EXECUTABLE
+else()
+ find_package(Python3 COMPONENTS Interpreter REQUIRED)
+ set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")
+endif()
include (CheckCXXSourceCompiles)
include (CheckCXXCompilerFlag)
include (CheckLibraryExists)
@@ -256,7 +263,10 @@ else()
find_package(Qt5Core)
endif()
if(Qt5Core_FOUND)
- set(_qtComponents Core Gui Widgets Network Xml Multimedia LinguistTools Test)
+ set(_qtComponents Core Gui Widgets Network Xml Multimedia LinguistTools)
+ if(BUILD_TESTING)
+ set(_qtComponents ${_qtComponents} Test)
+ endif()
if(WITH_DBUS)
set(_qtComponents ${_qtComponents} DBus)
endif()
@@ -472,12 +482,13 @@ if(ANDROID)
endif()
-enable_testing()
-add_test(NAME test_cli_functions
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/test/test_cli_functions.py)
-add_custom_target(check ${CMAKE_CTEST_COMMAND} --output-on-failure)
-if(NOT CMAKE_VERSION VERSION_LESS "3.17")
- list(APPEND CMAKE_CTEST_ARGUMENTS --output-on-failure)
+if(BUILD_TESTING)
+ add_test(NAME test_cli_functions
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/test/test_cli_functions.py)
+ add_custom_target(check ${CMAKE_CTEST_COMMAND} --output-on-failure)
+ if(NOT CMAKE_VERSION VERSION_LESS "3.17")
+ list(APPEND CMAKE_CTEST_ARGUMENTS --output-on-failure)
+ endif()
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c6c703ac..db067265 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,6 +8,6 @@ if(WITH_QML)
add_subdirectory(qml)
endif()
-if(BUILD_TEST_APP)
+if(BUILD_TESTING AND BUILD_TEST_APP)
add_subdirectory(test)
endif()
--
GitLab
|