CMake: Fix 3rd party library installation

Libraries created with qt_add_3rdparty_library should be installed
when the qmake 'installed' value is set in CONFIG. Introduce a new
INSTALL option to handle that in CMake projects.
If the value is provided, the library should always be installed
regardless of whether it's a shared or static library.

Fix the libraries to be installed to BINDIR/LIBDIR instead of
the config install dir.
Also install the CMake config files into the config install dir.

Change-Id: I86f1ef47680f08669a77db77e0d986f47d5fae2d
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-02-24 14:12:46 +01:00
parent ae9f0aa86a
commit 8ab59fd8b3

View File

@ -2969,7 +2969,7 @@ endfunction()
function(qt_add_3rdparty_library target)
# Process arguments:
qt_parse_all_arguments(arg "qt_add_3rdparty_library"
"SHARED;MODULE;STATIC;INTERFACE;EXCEPTIONS"
"SHARED;MODULE;STATIC;INTERFACE;EXCEPTIONS;INSTALL"
"OUTPUT_DIRECTORY"
"${__default_private_args};${__default_public_args}"
${ARGN}
@ -3062,7 +3062,7 @@ function(qt_add_3rdparty_library target)
${install_arguments}
)
if(NOT BUILD_SHARED_LIBS OR arg_SHARED)
if(NOT BUILD_SHARED_LIBS OR arg_INSTALL)
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
@ -3080,9 +3080,18 @@ function(qt_add_3rdparty_library target)
COMPATIBILITY AnyNewerVersion
)
qt_install(FILES
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
DESTINATION "${config_install_dir}"
COMPONENT Devel
)
qt_install(TARGETS ${target}
EXPORT "${export_name}"
DESTINATION "${config_install_dir}"
RUNTIME DESTINATION ${INSTALL_BINDIR}
LIBRARY DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
)
qt_install(EXPORT ${export_name}