From 8482cd6d8779ca243b3c06ddd7a1878a925f3b21 Mon Sep 17 00:00:00 2001 From: Qt6 Port Date: Thu, 12 Nov 2026 14:27:40 +0100 Subject: [PATCH] Remove the build tree automatically when switching cmk.sh -g/-G Switching the GUI between Qt5 and Qt6 left moc/ui files and objects from the previous Qt major behind; make clean after a reconfigure could still race with stale targets. cmk.sh now reads SLS_GUI_QT_MAJOR and SLS_USE_GUI from build/CMakeCache.txt before reconfiguring, and removes build/ when the requested major differs. Tested in both directions: -G after -g and -g after -G rebuild cleanly with no extra -c. Docs updated. --- README.md | 3 +++ cmk.sh | 23 +++++++++++++++++++++++ docs/src/gui_plotting.rst | 3 ++- docs/src/installation.rst | 3 +++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fa52f59cd..63449af99 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,9 @@ Usage: $0 [-b] [-c] [-d ] [-e] [-g] [-G] [-h] [-i] ./cmk.sh -cbgj9 # Qt 5 GUI (RHEL 7/older) ./cmk.sh -cbGj9 # Qt 6 GUI +# Switching between -g (Qt5) and -G (Qt6) removes the build directory +# automatically, so no separate -c is needed. + #For rebuilding only certain sections ./cmk.sh -tg #text client and Qt5 gui ./cmk.sh -tG #text client and Qt6 gui diff --git a/cmk.sh b/cmk.sh index f61bfd7a1..1ac263169 100755 --- a/cmk.sh +++ b/cmk.sh @@ -91,6 +91,9 @@ For rebuilding only certain sections ./cmk.sh -tg #text client and Qt5 gui ./cmk.sh -tG #text client and Qt6 gui ./cmk.sh -r #only receiver + +Switching between -g and -G removes the build tree automatically +(no extra -c needed). " ; exit 1; } @@ -233,6 +236,26 @@ fi +# Switching the GUI between Qt5 and Qt6 in an existing build tree leaves +# generated Qt/moc/ui files and objects from the other major behind; even +# make clean after a reconfigure can race with stale targets, so remove the +# whole build tree. Read the cache before -b removes it. +if [ $GUI -eq 1 ] && [ -f "$BUILDDIR/CMakeCache.txt" ]; then + requested_qt=5 + [ $QT6 -eq 1 ] && requested_qt=6 + cached_gui=$(grep -E '^SLS_USE_GUI:BOOL=' "$BUILDDIR/CMakeCache.txt" | head -1 | cut -d= -f2 || true) + cached_qt=$(grep -E '^SLS_GUI_QT_MAJOR:STRING=' "$BUILDDIR/CMakeCache.txt" | head -1 | cut -d= -f2 || true) + # Cache from before SLS_GUI_QT_MAJOR existed: that build was Qt6. + if [ "$cached_gui" = "ON" ] && [ -z "$cached_qt" ]; then + cached_qt=6 + fi + if [ "$cached_gui" = "ON" ] && [ -n "$cached_qt" ] && [ "$cached_qt" != "$requested_qt" ]; then + echo "Qt major changed from $cached_qt to $requested_qt: removing the build directory" + rm -rf -- "$BUILDDIR" + CLEAN=0 + fi +fi + #build dir doesnt exist if [ ! -d "$BUILDDIR" ] ; then echo "No Build Directory. Building of Cmake files required" diff --git a/docs/src/gui_plotting.rst b/docs/src/gui_plotting.rst index e85932a73..92c65c50f 100644 --- a/docs/src/gui_plotting.rst +++ b/docs/src/gui_plotting.rst @@ -134,4 +134,5 @@ a `qwt_*` header. The package metadata and documentation refer to the Qt runtime packages instead (`qt6-qtbase`/`qt5-qtbase` on RPM based systems, `qt6-base-dev`/`qtbase5-dev` on Debian/Ubuntu, `qt6-main`/`qt-main` in conda), selected by `SLS_GUI_QT_MAJOR` (or `cmk.sh -G` for Qt 6 and `-g` for -Qt 5). +Qt 5). Switching between the two cmk flags removes the build tree +automatically, so no extra `-c` is needed. diff --git a/docs/src/installation.rst b/docs/src/installation.rst index 6147d0d0a..562a37a7c 100644 --- a/docs/src/installation.rst +++ b/docs/src/installation.rst @@ -237,6 +237,9 @@ Example cmake options Comment ./cmk.sh -cbgj9 # Qt 5 GUI (RHEL 7/older) ./cmk.sh -cbGj9 # Qt 6 GUI + # Switching between -g (Qt5) and -G (Qt6) removes the build directory + # automatically, so no separate -c is needed. + #For rebuilding only certain sections ./cmk.sh -tg #text client and Qt5 gui ./cmk.sh -tG #text client and Qt6 gui