I have been struggling with the same linkage issue while trying to use QCustomPlot, and the following setup in my CMakeLists.txt
helped resolve it:
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets PrintSupport)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets PrintSupport)
...
target_link_libraries(QCustomPlot_temp PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::PrintSupport
)
Using Qt${QT_VERSION_MAJOR}
ensures compatibility with both Qt5 and Qt6, and properly links the required modules. Hope this helps someone else facing the same issue!
And this links also helps: