From 582fdf06d179ee17ff68c67fb2f55ac10b7b6e4a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 28 Apr 2021 09:23:59 +0200 Subject: Make a documentation-only build possible Packagers usually build Qt per repo, but the documentation must be built from the full Qt source archive to ensure that inter-repo links are set up correctly. When building the documentation, it's desirable to avoid building tools and re-use to tools of an existing Qt build. One now can do a documentation-only build by configuring Qt like this: cmake /path/to/Qt/source -GNinja \ -DQT_HOST_PATH=/path/to/Qt/installation and build the documentation with ninja docs To avoid building tools, this patch removes the DEPENDS arguments from some add_custom_target calls in QtDocsHelpers.cmake and makes another one conditional. The removed dependencies are added at the end of qt_internal_add_docs. Adding of tool dependencies is not done if QT_HOST_PATH is set. Fixes: QTBUG-88441 Change-Id: I3b7a908e22d252d2edcdc1dd522a78b8ad6c487e Reviewed-by: Alexandru Croitor --- cmake/QtDocsHelpers.cmake | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/cmake/QtDocsHelpers.cmake b/cmake/QtDocsHelpers.cmake index 593a72c90e..e2f75db213 100644 --- a/cmake/QtDocsHelpers.cmake +++ b/cmake/QtDocsHelpers.cmake @@ -31,7 +31,11 @@ function(qt_internal_add_docs) return() endif() - if(QT_SUPERBUILD) + set(tool_dependencies_enabled TRUE) + if(NOT "${QT_HOST_PATH}" STREQUAL "") + set(tool_dependencies_enabled FALSE) + set(doc_tools_dir "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}") + elseif(QT_SUPERBUILD) set(doc_tools_dir "${QtBase_BINARY_DIR}/${INSTALL_BINDIR}") else() set(doc_tools_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}") @@ -85,7 +89,6 @@ function(qt_internal_add_docs) # qtattributionsscanner add_custom_target(qattributionsscanner_${target} - DEPENDS ${qattributionsscanner_bin} COMMAND ${qtattributionsscanner_bin} ${PROJECT_SOURCE_DIR} --filter "QDocModule=${doc_target}" @@ -120,7 +123,6 @@ function(qt_internal_add_docs) ) add_custom_target(prepare_docs_${target} - DEPENDS ${qdoc_bin} COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args} ${qdoc_bin} ${prepare_qdoc_args} @@ -139,8 +141,12 @@ function(qt_internal_add_docs) ) foreach(target_prefix generate_top_level_docs generate_repo_docs generate_docs) + set(depends_arg "") + if(tool_dependencies_enabled) + set(depends_arg DEPENDS ${qdoc_bin}) + endif() add_custom_target(${target_prefix}_${target} - DEPENDS ${qdoc_bin} + ${depends_arg} COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args} ${qdoc_bin} ${generate_qdocs_args}) endforeach() @@ -158,8 +164,12 @@ function(qt_internal_add_docs) set(qch_file_path ${qdoc_qch_output_dir}/${qch_file_name}) foreach(target_prefix qch_top_level_docs qch_repo_docs qch_docs) + set(depends_arg "") + if(tool_dependencies_enabled) + set(depends_arg DEPENDS ${qhelpgenerator_bin}) + endif() add_custom_target(${target_prefix}_${target} - DEPENDS ${qhelpgenerator_bin} + ${depends_arg} COMMAND ${qhelpgenerator_bin} "${qdoc_output_dir}/${doc_target}.qhp" -o "${qch_file_path}" @@ -218,7 +228,9 @@ function(qt_internal_add_docs) # Make sure that the necessary tools are built when running, # for example 'cmake --build . --target generate_docs'. - qt_internal_add_doc_tool_dependency(qattributionsscanner_${target} qtattributionsscanner) - qt_internal_add_doc_tool_dependency(prepare_docs_${target} qdoc) - qt_internal_add_doc_tool_dependency(qch_docs_${target} qhelpgenerator) + if(tool_dependencies_enabled) + qt_internal_add_doc_tool_dependency(qattributionsscanner_${target} qtattributionsscanner) + qt_internal_add_doc_tool_dependency(prepare_docs_${target} qdoc) + qt_internal_add_doc_tool_dependency(qch_docs_${target} qhelpgenerator) + endif() endfunction() -- cgit v1.2.3