Skip to content

Commit

Permalink
[Cmake] Update FindPySide2Tools for PySide2 5.14 - issue #4229
Browse files Browse the repository at this point in the history
Since PySide2 5.14, 'pyside2-rcc' and 'pyside2-uic' have been renamed into plain 'rcc' and 'uic'.
This leads FindPySide2Tools.cmake to no longer find rcc/uic, as reported in bug #4229 (https://www.freecadweb.org/tracker/view.php?id=4229) and prevents compilation.
FindPySide2Tools has been updated accordingly.
  • Loading branch information
howetuft authored and yorikvanhavre committed Jan 8, 2020
1 parent 692fa7e commit 17ed2b1
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions cMake/FindPySide2Tools.cmake
Expand Up @@ -20,8 +20,24 @@ if(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(PYSIDE_BIN_DIR ${PYTHON_BIN_DIR})
endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

FIND_PROGRAM(PYSIDE2UICBINARY NAMES python2-pyside2-uic pyside2-uic pyside2-uic-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR})
FIND_PROGRAM(PYSIDE2RCCBINARY NAMES pyside2-rcc pyside2-rcc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR})
# 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)

IF(Qt5Core_VERSION LESS 5.14)
# Legacy (< 5.14)
FIND_PROGRAM(PYSIDE2UICBINARY NAMES python2-pyside2-uic pyside2-uic pyside2-uic-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR})
FIND_PROGRAM(PYSIDE2RCCBINARY NAMES pyside2-rcc pyside2-rcc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR})
set(UICOPTIONS "")
set(RCCOPTIONS "")
ELSE(Qt5Core_VERSION LESS 5.14)
# New (>= 5.14)
FIND_PROGRAM(PYSIDE2UICBINARY NAMES uic)
set(UICOPTIONS "--generator=python")
FIND_PROGRAM(PYSIDE2RCCBINARY NAMES rcc)
set(RCCOPTIONS "--generator=python" "--compress-algo=zlib" "--compress=1")
ENDIF(Qt5Core_VERSION LESS 5.14)

MACRO(PYSIDE_WRAP_UI outfiles)
FOREACH(it ${ARGN})
Expand All @@ -33,15 +49,15 @@ MACRO(PYSIDE_WRAP_UI outfiles)
#)
if(WIN32 OR APPLE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${PYSIDE2UICBINARY} ${infile} -o ${outfile}
COMMAND ${PYSIDE2UICBINARY} ${UICOPTIONS} ${infile} -o ${outfile}
MAIN_DEPENDENCY ${infile}
)
else()
# Especially on Open Build Service we don't want changing date like
# pyside2-uic generates in comments at beginning., which is why
# we follow the tool command with in-place sed.
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND "${PYSIDE2UICBINARY}" "${infile}" -o "${outfile}"
COMMAND "${PYSIDE2UICBINARY}" ${UICOPTIONS} "${infile}" -o "${outfile}"
COMMAND sed -i "/^# /d" "${outfile}"
MAIN_DEPENDENCY "${infile}"
)
Expand All @@ -60,15 +76,15 @@ MACRO(PYSIDE_WRAP_RC outfiles)
#)
if(WIN32 OR APPLE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${PYSIDE2RCCBINARY} ${infile} -o ${outfile}
COMMAND ${PYSIDE2RCCBINARY} ${RCCOPTIONS} ${infile} -o ${outfile}
MAIN_DEPENDENCY ${infile}
)
else()
# Especially on Open Build Service we don't want changing date like
# pyside-rcc generates in comments at beginning, which is why
# we follow the tool command with in-place sed.
ADD_CUSTOM_COMMAND(OUTPUT "${outfile}"
COMMAND "${PYSIDE2RCCBINARY}" "${infile}" ${PY_ATTRIBUTE} -o "${outfile}"
COMMAND "${PYSIDE2RCCBINARY}" ${RCCOPTIONS} "${infile}" ${PY_ATTRIBUTE} -o "${outfile}"
COMMAND sed -i "/^# /d" "${outfile}"
MAIN_DEPENDENCY "${infile}"
)
Expand Down

0 comments on commit 17ed2b1

Please sign in to comment.