CMake: Allow specifying an optional host tools path for doc generation

Introduce a new QT_OPTIONAL_TOOLS_PATH cmake variable that can be set
to a path where some of the documentation generation host tools might
be located.

This allows using specific builds of qdoc, qvkgen, qdbusxml2cpp and
qtattributionsscanner for documentation generation.

QT_HOST_PATH wouldn't be sufficient in this case, because it requires
all host tools to be installed for the given path, otherwise
configuration will fail

In contrast with QT_OPTIONAL_TOOLS_PATH we can specify the paths only
for the tools listed above, while continuing using other build tools
from the usual locations, either built or found.

As a drive-by, fix the usage of CMAKE_EXECUTABLE_SUFFIX to be based
on the host platform.

Task-number: QTBUG-128730
Change-Id: I2796be3a9772b106788ce63a4aed890516e8b716
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit aab8b7727d8acff989dbdf9b01ca7fb2b12da541)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2024-09-06 13:54:24 +02:00
parent de6615057e
commit 32a6d50301
3 changed files with 32 additions and 5 deletions

View File

@ -55,10 +55,22 @@ function(qt_create_qdbusxml2cpp_command target infile)
set(header_file_full "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.h")
set(source_file_full "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.cpp")
if(QT_OPTIONAL_TOOLS_PATH)
if(CMAKE_HOST_WIN32)
set(executable_suffix ".exe")
else()
set(executable_suffix "")
endif()
set(tool_path
"${QT_OPTIONAL_TOOLS_PATH}/${INSTALL_BINDIR}/qdbusxml2cpp${executable_suffix}")
else()
set(tool_path "${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp")
endif()
add_custom_command(OUTPUT "${header_file_full}" "${source_file_full}"
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${arg_FLAGS} "${option}"
COMMAND ${tool_path} ${arg_FLAGS} "${option}"
"${header_file}:${source_file}" "${absolute_in_file_path}"
DEPENDS "${absolute_in_file_path}" ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp
DEPENDS "${absolute_in_file_path}" ${tool_path}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND_EXPAND_LISTS
VERBATIM)

View File

@ -68,6 +68,10 @@ function(qt_internal_add_docs)
set(tool_dependencies_enabled FALSE)
set(doc_tools_bin "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}")
set(doc_tools_libexec "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}")
elseif(NOT "${QT_OPTIONAL_TOOLS_PATH}" STREQUAL "")
set(tool_dependencies_enabled FALSE)
set(doc_tools_bin "${QT_OPTIONAL_TOOLS_PATH}/${INSTALL_BINDIR}")
set(doc_tools_libexec "${QT_OPTIONAL_TOOLS_PATH}/${INSTALL_LIBEXECDIR}")
elseif(QT_SUPERBUILD)
set(doc_tools_bin "${QtBase_BINARY_DIR}/${INSTALL_BINDIR}")
set(doc_tools_libexec "${QtBase_BINARY_DIR}/${INSTALL_LIBEXECDIR}")
@ -76,9 +80,15 @@ function(qt_internal_add_docs)
set(doc_tools_libexec "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}")
endif()
set(qdoc_bin "${doc_tools_bin}/qdoc${CMAKE_EXECUTABLE_SUFFIX}")
set(qtattributionsscanner_bin "${doc_tools_libexec}/qtattributionsscanner${CMAKE_EXECUTABLE_SUFFIX}")
set(qhelpgenerator_bin "${doc_tools_libexec}/qhelpgenerator${CMAKE_EXECUTABLE_SUFFIX}")
if(CMAKE_HOST_WIN32)
set(executable_suffix ".exe")
else()
set(executable_suffix "")
endif()
set(qdoc_bin "${doc_tools_bin}/qdoc${executable_suffix}")
set(qtattributionsscanner_bin "${doc_tools_libexec}/qtattributionsscanner${executable_suffix}")
set(qhelpgenerator_bin "${doc_tools_libexec}/qhelpgenerator${executable_suffix}")
get_target_property(target_type ${target} TYPE)
if (NOT target_type STREQUAL "INTERFACE_LIBRARY")

View File

@ -940,6 +940,11 @@ if (QT_FEATURE_vulkan)
"${QT_HOST_PATH}"
"${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}"
"qvkgen${host_executable_suffix}")
elseif(QT_OPTIONAL_TOOLS_PATH)
qt_path_join(qvkgen
"${QT_OPTIONAL_TOOLS_PATH}"
"${INSTALL_LIBEXECDIR}"
"qvkgen${host_executable_suffix}")
else()
set(qvkgen "${QT_CMAKE_EXPORT_NAMESPACE}::qvkgen")
endif()