‘’‘find_package(Qt5 COMPONENTS Widgets REQUIRED CONFIG)’’’
seems to work, as Qt5_FOUND is true, and Qt5Widgets_INCLUDE_DIRS has the correct include folders. However, Qt5Widgets_LIBRARIES only has “Qt5::Widgets”. How do I get hold of the the Widgets library names and their folders?
Qt5::Widgets is a target rather than a library. But that allows you
target_link_libraries(<your target name> Qt5::Widgets) to
set properties on
<your target name> including the location of
needed Qt5 headers, the location of the appropriate Qt5 library, etc.
And if target_link_libraries is not enough, you can use generator
expressions based on the Qt5::Widgets target to figure out everything
else you might need to build
<your target name>.
Thanks for the hints! I found generator expressions to be most useful e.g.
** OUTPUT wname.txt**
** CONTENT $<TARGET_LINKER_FILE_NAME:Qt5::Widgets>\n**
creates the file wname.txt with content