From f3655660f3a39dee31a825fcd3c54bfd1ae066b4 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 12 Aug 2026 18:59:22 +0000 Subject: [PATCH] Qt4: derive QtSingleApplication paths from qmake location, not QT_INCLUDE_DIR FindQt4's QT_INCLUDE_DIR/QT_LIBRARY_DIR point at the core Qt4 modules' own location (/opt/local/include/qt4 on this MacPorts setup), but the "qt4 1.0" PortGroup used to build qtsingleapplication-qt4 installs everything under the Qt4 kit's own prefix instead (/opt/local/libexec/qt4, the directory containing bin/qmake) -- a different base entirely. Confirmed against the actual installed layout: headers under libexec/qt4/include/QtSingleApplication, libs under libexec/qt4/lib. Derive that prefix from QT_QMAKE_EXECUTABLE's own directory instead of trusting QT_INCLUDE_DIR/QT_LIBRARY_DIR. --- CMake/Includes/ProjectExternals.cmake | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/CMake/Includes/ProjectExternals.cmake b/CMake/Includes/ProjectExternals.cmake index 5d05afb..1da4009 100644 --- a/CMake/Includes/ProjectExternals.cmake +++ b/CMake/Includes/ProjectExternals.cmake @@ -42,12 +42,19 @@ if(WITH_QT4) # devel/qtsingleapplication-qt4 port instead of building it ourselves. # That port ships no CMake package config/module of its own (and # find_path()/find_library() don't reliably locate it either), so - # its files are addressed directly under the Qt4 kit's own - # include/lib dirs. The MacPorts Portfile is expected to declare a + # its files are addressed directly. They are NOT under Qt4's own + # QT_INCLUDE_DIR/QT_LIBRARY_DIR (on macOS/MacPorts those point at + # e.g. /opt/local/include/qt4, the core Qt4 modules' own location); + # the "qt4 1.0" MacPorts PortGroup used to build this port instead + # installs everything under the Qt4 kit's own prefix -- the same + # directory that ships bin/qmake, i.e. qmake's own parent-of-parent + # directory. The MacPorts Portfile is expected to declare a # dependency on qtsingleapplication-qt4, so its presence there can # be assumed rather than searched for. - set(QTSINGLEAPPLICATION_INCLUDE_DIR "${QT_INCLUDE_DIR}/QtSingleApplication") - set(QTSINGLEAPPLICATION_LIBRARY "${QT_LIBRARY_DIR}/libQtSingleApplication.dylib") + get_filename_component(_qt4_kit_bin_dir "${QT_QMAKE_EXECUTABLE}" DIRECTORY) + get_filename_component(_qt4_kit_dir "${_qt4_kit_bin_dir}" DIRECTORY) + set(QTSINGLEAPPLICATION_INCLUDE_DIR "${_qt4_kit_dir}/include/QtSingleApplication") + set(QTSINGLEAPPLICATION_LIBRARY "${_qt4_kit_dir}/lib/libQtSingleApplication.dylib") if(NOT EXISTS "${QTSINGLEAPPLICATION_INCLUDE_DIR}/QtSingleApplication" OR NOT EXISTS "${QTSINGLEAPPLICATION_LIBRARY}") message(FATAL_ERROR "QtSingleApplication not found under the Qt4 kit " "(looked for ${QTSINGLEAPPLICATION_INCLUDE_DIR}/QtSingleApplication and ${QTSINGLEAPPLICATION_LIBRARY}); " -- 2.43.0