Skip to content

Commit

Permalink
CMake: Allow specifying an optional host tools path for doc generation
Browse files Browse the repository at this point in the history
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.

Pick-to: 6.8
Task-number: QTBUG-128730
Change-Id: I2796be3a9772b106788ce63a4aed890516e8b716
Reviewed-by: Alexey Edelev <[email protected]>
  • Loading branch information
alcroito committed Oct 30, 2024
1 parent 3066e9e commit aab8b77
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
16 changes: 14 additions & 2 deletions cmake/QtDbusHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 13 additions & 3 deletions cmake/QtDocsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,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()
Expand Down

0 comments on commit aab8b77

Please sign in to comment.