summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2020-10-27 17:35:58 +0100
committerKai Koehne <kai.koehne@qt.io>2020-10-29 08:53:07 +0100
commit342cc61d3e91424695ad6bc369a4ea59412ee9b8 (patch)
tree5b2756d0eb155b62e940ce293069d44467909782
parent7372dde4ec6cb32448ea026f48b5f5ea517f778d (diff)
downloadqtbase-342cc61d3e91424695ad6bc369a4ea59412ee9b8.tar.gz
CMake: Support installing extra cmake files for tools
Add an EXTRA_CMAKE_FILES argument to qt_internal_add_tool() that allows tools to install an additional Macro.cmake file. This is modelled after similar functionality in qt_internal_add_module. Task-number: QTBUG-87870 Change-Id: I80838b8966f1018fdd379b1da877b6bc418de075 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--cmake/QtModuleToolsConfig.cmake.in4
-rw-r--r--cmake/QtToolHelpers.cmake33
2 files changed, 36 insertions, 1 deletions
diff --git a/cmake/QtModuleToolsConfig.cmake.in b/cmake/QtModuleToolsConfig.cmake.in
index 498c0fca83..a714a7b7f2 100644
--- a/cmake/QtModuleToolsConfig.cmake.in
+++ b/cmake/QtModuleToolsConfig.cmake.in
@@ -15,4 +15,8 @@ if (NOT QT_NO_CREATE_TARGETS)
endif()
endif()
+foreach(extra_cmake_include @extra_cmake_includes@)
+ include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}")
+endforeach()
+
@extra_cmake_statements@
diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake
index 106dc8720d..06bf171454 100644
--- a/cmake/QtToolHelpers.cmake
+++ b/cmake/QtToolHelpers.cmake
@@ -10,7 +10,7 @@
function(qt_internal_add_tool target_name)
qt_tool_target_to_name(name ${target_name})
qt_parse_all_arguments(arg "qt_add_tool" "BOOTSTRAP;NO_QT;NO_INSTALL"
- "TOOLS_TARGET;${__default_target_info_args}"
+ "TOOLS_TARGET;EXTRA_CMAKE_FILES;${__default_target_info_args}"
"${__default_private_args}" ${ARGN})
# Handle case when a tool does not belong to a module and it can't be built either (like
@@ -165,6 +165,12 @@ function(qt_internal_add_tool target_name)
endif()
endif()
+ if(arg_EXTRA_CMAKE_FILES)
+ set_target_properties(${target_name} PROPERTIES
+ EXTRA_CMAKE_FILES "${arg_EXTRA_CMAKE_FILES}"
+ )
+ endif()
+
# If building with a multi-config configuration, the main configuration tool will be placed in
# ./bin, while the rest will be in <CONFIG> specific subdirectories.
qt_get_tool_cmake_configuration(tool_cmake_configuration)
@@ -234,6 +240,9 @@ function(qt_export_tools module_name)
# List of package dependencies that need be find_package'd when using the Tools package.
set(package_deps "")
+ # Additional cmake files to install
+ set(extra_cmake_files "")
+
foreach(tool_name ${QT_KNOWN_MODULE_${module_name}_TOOLS})
# Specific tools can have package dependencies.
# e.g. qtwaylandscanner depends on WaylandScanner (non-qt package).
@@ -242,6 +251,14 @@ function(qt_export_tools module_name)
list(APPEND package_deps "${extra_packages}")
endif()
+ get_target_property(_extra_cmake_files "${tool_name}" EXTRA_CMAKE_FILES)
+ if (_extra_cmake_files)
+ foreach(cmake_file ${_extra_cmake_files})
+ file(COPY "${cmake_file}" DESTINATION "${config_build_dir}")
+ list(APPEND extra_cmake_files "${cmake_file}")
+ endforeach()
+ endif()
+
if (CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
string(REGEX REPLACE "_native$" "" tool_name ${tool_name})
endif()
@@ -260,6 +277,12 @@ endif()
string(APPEND extra_cmake_statements
"set(${QT_CMAKE_EXPORT_NAMESPACE}${module_name}Tools_TARGETS \"${tool_targets}\")")
+ set(extra_cmake_includes "")
+ foreach(extra_cmake_file ${extra_cmake_files})
+ get_filename_component(extra_cmake_include "${extra_cmake_file}" NAME)
+ list(APPEND extra_cmake_includes "${extra_cmake_include}")
+ endforeach()
+
# Extract package dependencies that were determined in QtPostProcess, but only if ${module_name}
# is an actual target.
# module_name can be a non-existent target, if the tool doesn't have an existing associated
@@ -284,6 +307,14 @@ endif()
COMPONENT Devel
)
+ if(extra_cmake_files)
+ qt_install(FILES
+ ${extra_cmake_files}
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+ endif()
+
# Configure and install the ${module_name}Tools package Config file.
configure_package_config_file(
"${QT_CMAKE_DIR}/QtModuleToolsConfig.cmake.in"