Build: Simplify documentation target creation

We don't have to rely on qdoc being located alongside qmake anymore,
because nowadays Qt defines a Qt::doc target with IMPORTED_LOCATION set,
so we can use that directly.

Change-Id: I450578e711e0835e00320251dcadc78c1f02ab7d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2023-02-28 10:09:12 +01:00
parent 6dc4160a40
commit 00c79cc1b7

View File

@@ -43,23 +43,6 @@ function(qt5_query_qmake)
endforeach()
endfunction()
# Find programs:
function(_doc_find_program result_var)
if (NOT TARGET Qt::qmake)
message(FATAL_ERROR "QDoc is only available in Qt5 projects")
endif()
get_target_property(_qmake_binary Qt::qmake IMPORTED_LOCATION)
get_filename_component(_qmake_dir "${_qmake_binary}" DIRECTORY)
find_program("_prg_${result_var}" ${ARGN} HINTS "${_qmake_dir}")
if ("_prg_${result_var}" STREQUAL "_prg_${result_var}-NOTFOUND")
set("_prg_${result_var}" "${result_var}-NOTFOUND")
message(WARNING "Could not find binary for ${result_var}")
endif()
set(${result_var} "${_prg_${result_var}}" PARENT_SCOPE)
endfunction()
function(_setup_doc_targets)
# Set up important targets:
if (NOT TARGET html_docs)
@@ -78,6 +61,11 @@ function(_setup_qdoc_targets _qdocconf_file _retval)
cmake_parse_arguments(_arg "" "HTML_DIR;INSTALL_DIR;POSTFIX"
"INDEXES;INCLUDE_DIRECTORIES;FRAMEWORK_PATHS;ENVIRONMENT_EXPORTS" ${ARGN})
if (NOT TARGET Qt::qdoc)
message(WARNING "qdoc missing: No documentation targets were generated. Add find_package(Qt5 COMPONENTS Help) to CMake to enable.")
return()
endif()
foreach(_index ${_arg_INDEXES})
list(APPEND _qdoc_index_args "-indexdir;${_index}")
endforeach()
@@ -90,9 +78,9 @@ function(_setup_qdoc_targets _qdocconf_file _retval)
list(APPEND _env "${_export}=${${_export}}")
endforeach()
set(_full_qdoc_command "${_qdoc}")
get_target_property(_full_qdoc_command Qt::qdoc IMPORTED_LOCATION)
if (_env)
set(_full_qdoc_command "${CMAKE_COMMAND}" "-E" "env" ${_env} "${_qdoc}")
set(_full_qdoc_command "${CMAKE_COMMAND}" "-E" "env" ${_env} "${_full_qdoc_command}")
endif()
if (_arg_HTML_DIR STREQUAL "")
@@ -182,12 +170,6 @@ endfunction()
function(qdoc_build_qdocconf_file _qdocconf_file)
_setup_doc_targets()
_doc_find_program(_qdoc NAMES qdoc qdoc-qt5)
if (_qdoc STREQUAL "_prg__qdoc-NOTFOUND")
message(WARNING "No qdoc binary found: No documentation targets were generated")
return()
endif()
cmake_parse_arguments(_arg "QCH" "HTML_DIR;QCH_DIR;INSTALL_DIR;POSTFIX"
"INDEXES;INCLUDE_DIRECTORIES;FRAMEWORK_PATHS;ENVIRONMENT_EXPORTS" ${ARGN})
if (_arg_UNPARSED_ARGUMENTS)
@@ -206,7 +188,7 @@ function(qdoc_build_qdocconf_file _qdocconf_file)
FRAMEWORK_PATHS ${_arg_FRAMEWORK_PATHS}
)
if (_arg_QCH)
if (_arg_QCH AND _html_outputdir)
_setup_qhelpgenerator_targets("${_qdocconf_file}" "${_html_outputdir}"
QCH_DIR "${_arg_QCH_DIR}" INSTALL_DIR "${_arg_INSTALL_DIR}")
endif()