summaryrefslogtreecommitdiff
path: root/media-gfx/freecad/files/freecad-0.19.4-backport-correctly-find-PySide2Tools.patch
blob: b297727033db632497172a5f678bfdf4f56e1d57 (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
100
101
102
103
104
105
106
From https://github.com/FreeCAD/FreeCAD/tree/6b062b25e118fc6d260d8caff6cf46fafd6cfa0f
From: Bernd Waibel <waebbl-gentoo@posteo.net>
Date: Sat, 2 Apr 2022 09:30:09 +0200
Subject: [PATCH] backport correctly find PySide2Tools

Backported from current HEAD

Signed-off-by: Bernd Waibel <waebbl-gentoo@posteo.net>
--- a/cMake/FindPySide2Tools.cmake
+++ b/cMake/FindPySide2Tools.cmake
@@ -23,7 +23,7 @@ endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 # Since Qt v5.14, pyside2-uic and pyside2-rcc are directly provided by Qt5Core uic and rcc, with '-g python' option
 # We test Qt5Core version to act accordingly
 
-FIND_PACKAGE(Qt5Core)
+FIND_PACKAGE(Qt5 COMPONENTS Core)
 
 IF(Qt5Core_VERSION VERSION_LESS 5.14)
   # Legacy (< 5.14)
@@ -33,13 +33,20 @@ IF(Qt5Core_VERSION VERSION_LESS 5.14)
   set(RCCOPTIONS "")
 ELSE(Qt5Core_VERSION VERSION_LESS 5.14)
   # New (>= 5.14)
-  FIND_PROGRAM(PYSIDE2UICBINARY NAMES uic-qt5 uic pyside2-uic)
-  set(UICOPTIONS "--generator=python")
-  FIND_PROGRAM(PYSIDE2RCCBINARY NAMES rcc-qt5 rcc pyside2-rcc)
-  set(RCCOPTIONS "--generator=python" "--compress-algo=zlib" "--compress=1")
+  if (TARGET Qt::uic)
+    get_property(PYSIDE2UICBINARY TARGET Qt::uic PROPERTY LOCATION)
+    set(UICOPTIONS "--generator=python")
+  endif()
+  if (TARGET Qt::rcc)
+    get_property(PYSIDE2RCCBINARY TARGET Qt::rcc PROPERTY LOCATION)
+    set(RCCOPTIONS "--generator=python" "--compress-algo=zlib" "--compress=1")
+  endif()
 ENDIF(Qt5Core_VERSION VERSION_LESS 5.14)
 
 MACRO(PYSIDE_WRAP_UI outfiles)
+  if (NOT PYSIDE2UICBINARY)
+    message(FATAL_ERROR "Qt uic is required for generating ${ARGN}")
+  endif()
   FOREACH(it ${ARGN})
     GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
     GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
@@ -58,7 +65,7 @@ MACRO(PYSIDE_WRAP_UI outfiles)
         # we follow the tool command with in-place sed.
         ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
           COMMAND "${PYSIDE2UICBINARY}" ${UICOPTIONS} "${infile}" -o "${outfile}"
-          COMMAND sed -i "/^# /d" "${outfile}"
+          COMMAND sed "/^# /d" "${outfile}" >"${outfile}.tmp" && mv "${outfile}.tmp" "${outfile}"
           MAIN_DEPENDENCY "${infile}"
         )
     endif()
@@ -67,6 +74,9 @@ MACRO(PYSIDE_WRAP_UI outfiles)
 ENDMACRO (PYSIDE_WRAP_UI)
 
 MACRO(PYSIDE_WRAP_RC outfiles)
+  if (NOT PYSIDE2RCCBINARY)
+    message(FATAL_ERROR "Qt rcc is required for generating ${ARGN}")
+  endif()
   FOREACH(it ${ARGN})
     GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
     GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
@@ -85,7 +95,7 @@ MACRO(PYSIDE_WRAP_RC outfiles)
         # we follow the tool command with in-place sed.
         ADD_CUSTOM_COMMAND(OUTPUT "${outfile}"
           COMMAND "${PYSIDE2RCCBINARY}" ${RCCOPTIONS} "${infile}" ${PY_ATTRIBUTE} -o "${outfile}"
-          COMMAND sed -i "/^# /d" "${outfile}"
+          COMMAND sed "/^# /d" "${outfile}" >"${outfile}.tmp" && mv "${outfile}.tmp" "${outfile}"
           MAIN_DEPENDENCY "${infile}"
         )
     endif()
@@ -93,20 +103,17 @@ MACRO(PYSIDE_WRAP_RC outfiles)
   ENDFOREACH(it)
 ENDMACRO (PYSIDE_WRAP_RC)
 
-IF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY})
-   set(PYSIDE2_TOOLS_FOUND TRUE)
-ENDIF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY})
-
 if(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY)
+  set(PYSIDE2_TOOLS_FOUND TRUE)
+  if (NOT PySide2Tools_FIND_QUIETLY)
+    message(STATUS "Found PySide2 tools: ${PYSIDE2UICBINARY}, ${PYSIDE2RCCBINARY}")
+  endif (NOT PySide2Tools_FIND_QUIETLY)
+else(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY)
+  if(PySide2Tools_FIND_REQUIRED)
+    message(FATAL_ERROR "PySide2 tools could not be found, but are required.")
+  else(PySide2Tools_FIND_REQUIRED)
     if (NOT PySide2Tools_FIND_QUIETLY)
-        message(STATUS "Found PySide2 tools: ${PYSIDE2UICBINARY}, ${PYSIDE2RCCBINARY}")
+      message(STATUS "PySide2 tools: not found.")
     endif (NOT PySide2Tools_FIND_QUIETLY)
-else(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY)
-    if(PySide2Tools_FIND_REQUIRED)
-        message(FATAL_ERROR "PySide2 tools could not be found, but are required.")
-    else(PySide2Tools_FIND_REQUIRED)
-        if (NOT PySide2Tools_FIND_QUIETLY)
-                message(STATUS "PySide2 tools: not found.")
-        endif (NOT PySide2Tools_FIND_QUIETLY)
-    endif(PySide2Tools_FIND_REQUIRED)
+  endif(PySide2Tools_FIND_REQUIRED)
 endif(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY)
-- 
2.35.1