Is there a way of using install(TARGETS… to install the Qt libraries, together with their namelinks, on Linux?
I’d expect the following to work, but it does not, and I don’t understand why:
# First locate the Qt installation
find_package(Qt5 COMPONENTS Core Gui Widgets Designer Test REQUIRED PATHS "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5" NO_DEFAULT_PATH)
# Verify that Qt5::Core is recognised as a target,
# and print out the location where its files were found
get_property(QT_CORE_INCLUDE_DIRS TARGET Qt5::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
list(GET QT_CORE_INCLUDE_DIRS 0 QT_CORE_MAIN_INCLUDE_DIR)
get_filename_component(QT_MAIN_DIR ${QT_CORE_MAIN_INCLUDE_DIR}/.. ABSOLUTE)
message("-- Qt version ${Qt5Core_VERSION_STRING} was located at ${QT_MAIN_DIR}")
set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTORCC ON)
set (CMAKE_AUTOUIC ON)
install(TARGETS Qt5::Core Qt5::Gui Qt5::Widgets
LIBRARY
DESTINATION myInstallDirectory)
When I run CMake on this script, the output is:
-- Qt version 5.12.5 was located at [ ...exactly where I expected to find it...]
CMake Error at configureQT5.cmake::[line no.] (install):
install TARGETS given target "Qt5::Core" which does not exist.
I’ve successfully used Qt5::Core as a target just a few lines previously in the file, so why does it suddenly not exist?