From 8ab59fd8b358f6aee94b5b2907209170b28acaca Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 24 Feb 2020 14:12:46 +0100 Subject: [PATCH] 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 Reviewed-by: Simon Hausmann --- cmake/QtBuild.cmake | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 7941bcbe16..48c38f3d8a 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -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}