CMake: honor CMAKE_INSTALL_INCLUDEDIR in exported target

Remove the hardcode to the 'include' directory in the CMake
exported target.

This will let the user correctly access the headers when
building a client application with a QHotkey package that
is installed with a CMAKE_INSTALL_INCLUDEDIR different
than 'include'.
This commit is contained in:
Daniel Bermond
2021-10-01 21:39:55 +03:00
committed by Hennadii Chernyshchyk
parent 25f21849b3
commit 6b3cc35bbd
+4 -3
View File
@@ -57,10 +57,12 @@ add_library(qhotkey ${SRC_FILES} ${MOC_HEADERS})
add_library(QHotkey::QHotkey ALIAS qhotkey)
target_link_libraries(qhotkey ${LIBS})
include(GNUInstallDirs)
target_include_directories(qhotkey
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/QHotkey>
$<INSTALL_INTERFACE:include>)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(qhotkey PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
@@ -71,7 +73,6 @@ if(QHOTKEY_EXAMPLES)
endif()
if(QHOTKEY_INSTALL)
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/QHotkey)
install(
@@ -82,7 +83,7 @@ if(QHOTKEY_INSTALL)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/qhotkey.h
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/QHotkey
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT QHotkeyConfig DESTINATION ${INSTALL_CONFIGDIR})
export(TARGETS qhotkey FILE QHotkeyConfig.cmake)