Currently we list out the Qt dependencies twice, and then the library names once, for a total of three times. If these need to be added to, removed, or changed, currently this requires three places to be changed.
This PR changes it to being specified once, and the required syntax differences are done programmatically.
OLD WAY:
find_packages(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Your Dependencies Go Here)
find_packages(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Your Dependencies Go Here)
*** lots of cmake in between***
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Your
Qt${QT_VERSION_MAJOR}::Dependencies
Qt${QT_VERSION_MAJOR}::Go
Qt${QT_VERSION_MAJOR}::Here
NEW WAY:
set(QT_REQUIRED_COMPONENTS Your Dependencies Go Here)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS ${QT_REQUIRED_COMPONENTS})
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${QT_REQUIRED_COMPONENTS})
*** lots of cmake in between***
set(QT_REQUIRED_COMPONENT_LIBS ${QT_REQUIRED_COMPONENTS})
list(TRANSFORM QT_REQUIRED_COMPONENT_LIBS PREPEND "Qt${QT_VERSION_MAJOR}::")
target_link_libraries(${PROJECT_NAME} PRIVATE
${QT_REQUIRED_COMPONENT_LIBS}
Currently we list out the Qt dependencies twice, and then the library names once, for a total of three times. If these need to be added to, removed, or changed, currently this requires three places to be changed.
This PR changes it to being specified once, and the required syntax differences are done programmatically.
OLD WAY:
NEW WAY: