Fixed linking for HighGUI against Qt 6.9 and newer

Use `link_libraries` instead of `add_defintions` to link against Qt 6.9
and newer to avoid un-expanded generator expressions from Qt cmake files
being appended to linker flags when building the HighGUI module.

The actual bug is likely in how Qt cmake files end up with these
un-expanded generator expressions in the first place — see discussion in
https://bugreports.qt.io/browse/QTBUG-134774 — but the recommended way
to link against the library is to use `link_libraries` anyway, so this
fix should do the trick.

Fixes issue #27223.
This commit is contained in:
Atri Bhattacharya 2025-10-15 21:49:04 +05:30
parent 563ef8ff97
commit e7728bb27d

View File

@ -125,7 +125,7 @@ elseif(HAVE_QT)
endif() endif()
foreach(dt_dep ${qt_deps}) foreach(dt_dep ${qt_deps})
add_definitions(${Qt${QT_VERSION_MAJOR}${dt_dep}_DEFINITIONS}) link_libraries(${Qt${QT_VERSION_MAJOR}${dt_dep}})
include_directories(${Qt${QT_VERSION_MAJOR}${dt_dep}_INCLUDE_DIRS}) include_directories(${Qt${QT_VERSION_MAJOR}${dt_dep}_INCLUDE_DIRS})
list(APPEND HIGHGUI_LIBRARIES ${Qt${QT_VERSION_MAJOR}${dt_dep}_LIBRARIES}) list(APPEND HIGHGUI_LIBRARIES ${Qt${QT_VERSION_MAJOR}${dt_dep}_LIBRARIES})
endforeach() endforeach()