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>
This commit is contained in:
parent
7372dde4ec
commit
342cc61d3e
@ -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@
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user