summaryrefslogtreecommitdiff
blob: d5b74ca561379dd8091f85ba2642063e54a62b30 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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 1/2] 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


From 1e264e918686d5d09a5457513f3aadeea25d6e5e Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 31 Jan 2021 23:43:49 +0100
Subject: [PATCH 2/2] Use CMake FindPython3 module if available (CMake >=3.12)

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

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