Currently, when a user/packager builds and installs QHotkey system-wide with a custom CMAKE_INSTALL_INCLUDEDIR, the headers are in fact installed to the correct path chosen by CMAKE_INSTALL_INCLUDEDIR, but the CMake exported target becomes broken.
This is happening because the include directory is hardcoded in CMakeLists.txt. As a consequence, when a client application tries to access QHotkey by find_package(), the imported CMake target will tell that headers are installed at <prefix>/include due to the include hardcode, while in fact the headers will be installed at <prefix>/CMAKE_INSTALL_INCLUDEDIR.
In such explained situation, this will lead to the following compile error:
fatal error: QHotkey: No such file or directory
This commit removes the hardcode to the include directory in the CMake exported target, replacing it with CMAKE_INSTALL_INCLUDEDIR as the CMake exporting documentation recommends. 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.
I think it's also a good idea to remove the ending slash from the install(FILES <...>) statement, as it should match exactly the same path that is being exported by $<INSTALL_INTERFACE:CMAKE_INSTALL_INCLUDEDIR>, as also shown on the same pointed documentation above.
Currently, when a user/packager builds and installs QHotkey system-wide with a custom
CMAKE_INSTALL_INCLUDEDIR
, the headers are in fact installed to the correct path chosen byCMAKE_INSTALL_INCLUDEDIR
, but the CMake exported target becomes broken.This is happening because the
include
directory is hardcoded in CMakeLists.txt. As a consequence, when a client application tries to access QHotkey byfind_package()
, the imported CMake target will tell that headers are installed at<prefix>/include
due to theinclude
hardcode, while in fact the headers will be installed at<prefix>/CMAKE_INSTALL_INCLUDEDIR
.In such explained situation, this will lead to the following compile error:
This commit removes the hardcode to the
include
directory in the CMake exported target, replacing it withCMAKE_INSTALL_INCLUDEDIR
as the CMake exporting documentation recommends. This will let the user correctly access the headers when building a client application with a QHotkey package that is installed with aCMAKE_INSTALL_INCLUDEDIR
different thaninclude
.I think it's also a good idea to remove the ending slash from the
install(FILES <...>)
statement, as it should match exactly the same path that is being exported by$<INSTALL_INTERFACE:CMAKE_INSTALL_INCLUDEDIR>
, as also shown on the same pointed documentation above.