Reputation: 9124
I have this snippet and it works fine:
find_package(Qt5 COMPONENTS Core REQUIRED)
target_link_libraries( myproj Qt5::Core )
target_include_directories( myproj PRIVATE ${Qt5Core_INCLUDE_DIRS} )
because I want to use Qwt. Now I run find_library( LIB_qwt qwt )
and get the path to the .so
in a breeze. But how do I get the header path and add it to target_include_directories()
?
Also do I really need to manually include Qt? If I don't (but I include Qwt files in an ugly way) the headers of Qwt break compilation by not discovering Qt.
This is my Qwt installation: libqwt-qt5-dev
.
Upvotes: 1
Views: 1684
Reputation: 970
You should be able to add ${LIB_qwt_INCLUDE_DIR}
or ${QWT_INCLUDE_DIR}
to target_include_directories
after find_library( LIB_qwt qwt )
. You must include Qt manually.
If that doesn't work you can search for the path yourself, you could use find_path
like so:
find_path(QWT_INCLUDE_DIR qwt.h)
target_include_directories( myproj PRIVATE ${Qt5Core_INCLUDE_DIRS} ${QWT_INCLUDE_DIR})
qwt.h
must be somewhere on the path obviously.
Upvotes: 2