Skip to content

Commit

Permalink
[CMake] Use imported executable targets for finding Qt uic/rcc
Browse files Browse the repository at this point in the history
Commit 024bde6 ("Update FindPySide2Tools.cmake") removed the
versioned names of uic/rcc, which are at least used on openSUSE
and Fedora.

Instead of determining the path of uic/rcc manually, just use
the imported executable targets. rcc comes from QtCore, while
uic comes from QtWidgets.

Fixes FreeCAD#6445.
  • Loading branch information
StefanBruens authored and wwmayer committed Feb 26, 2022
1 parent a5bc46a commit 4e9363c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cMake/FindPySide2Tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 Widgets)

IF(Qt5Core_VERSION VERSION_LESS 5.14)
# Legacy (< 5.14)
Expand All @@ -33,10 +33,14 @@ IF(Qt5Core_VERSION VERSION_LESS 5.14)
set(RCCOPTIONS "")
ELSE()
# New (>= 5.14)
FIND_PROGRAM(PYSIDE2UICBINARY NAMES uic )#pyside2-uic)
set(UICOPTIONS "--generator=python")
FIND_PROGRAM(PYSIDE2RCCBINARY NAMES 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)
Expand Down Expand Up @@ -93,11 +97,8 @@ 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)
Expand Down

0 comments on commit 4e9363c

Please sign in to comment.