summaryrefslogtreecommitdiff
blob: 4db47a2f1affc0b3d1fd837615331e5265acbe45 (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
From 4efe62089eff54ac844c70382d432f2abb24c06e Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 31 Jan 2021 20:38:41 +0100
Subject: [PATCH] Use include(CTest) and BUILD_TESTING to make Qt5Test and
 Python optional

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92d50265..557a208d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -211,8 +211,11 @@ endif()
 set(CFG_QMLSRCDIR "${kid3_SOURCE_DIR}/src/qml")
 
 find_package(Threads)
-set(Python_ADDITIONAL_VERSIONS 3)
-find_package(PythonInterp REQUIRED)
+include(CTest)
+if(BUILD_TESTING)
+  set(Python_ADDITIONAL_VERSIONS 3)
+  find_package(PythonInterp REQUIRED)
+endif()
 include (CheckCXXSourceCompiles)
 include (CheckCXXCompilerFlag)
 include (CheckLibraryExists)
@@ -256,7 +259,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 +478,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()
 
 
-- 
2.30.0