From af6a42204949e41406e148a4520f95160bc8cc60 Mon Sep 17 00:00:00 2001 From: "Cathy J. Fitzpatrick" Date: Sun, 3 Nov 2024 12:01:31 -0800 Subject: [PATCH] build: use parallelization except on Windows This is similar to LizardByte/Sunshine#3361, except now multithreaded processing is not used on Windows. Unlike LizardByte/Sunshine#3361, we're now enabling parallelization for both dot graph generation and other doxygen processing tasks as well (except on Windows). To check for Windows, we use the macro `CMAKE_HOST_WIN32` rather than the more well-known `WIN32`, because what matters here is the host platform, not the target platform. In most cases, these will be the same, but the issue with parallelization is related to Windows as a host, not a target. In other words, using Windows to build the documentation for a macOS project should still be single-threaded. --- CMakeLists.txt | 10 ++++++++++ doxyconfig-Doxyfile | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f6a910..3c7f9fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,15 @@ add_custom_command( file(RELATIVE_PATH DOXYGEN_BUILD_DIR_RELATIVE "${SOURCE_DOCS_DIR}" "${DOXYGEN_BUILD_DIR_CMAKE}") message(STATUS "DOXYGEN_BUILD_DIR_RELATIVE: ${DOXYGEN_BUILD_DIR_RELATIVE}") +if(CMAKE_HOST_WIN32) + # On Windows, we have to build the documentation using only a single thread to + # avoid the build mysteriously taking forever. + # See https://github.com/doxygen/doxygen/issues/9694 + set(DOXYGEN_NUM_THREADS 1) +else() + set(DOXYGEN_NUM_THREADS 0) +endif() + # build docs add_custom_target(docs ALL COMMENT "Building Doxygen documentation" @@ -99,6 +108,7 @@ add_custom_target(docs ALL COMMAND ${CMAKE_COMMAND} -E env READTHEDOCS_OUTPUT=${DOXYGEN_BUILD_DIR_RELATIVE} READTHEDOCS_VERSION=${DOXYGEN_PROJECT_VERSION} + DOXYCONFIG_THREADS=${DOXYGEN_NUM_THREADS} ${DOXYGEN_EXECUTABLE} doxyconfig-Doxyfile VERBATIM DEPENDS FONT_AWESOME_FILES diff --git a/doxyconfig-Doxyfile b/doxyconfig-Doxyfile index 9978cc5..dcf8f76 100644 --- a/doxyconfig-Doxyfile +++ b/doxyconfig-Doxyfile @@ -107,7 +107,6 @@ DISABLE_INDEX = NO DOCBOOK_OUTPUT = docbook DOT_GRAPH_MAX_NODES = 50 DOT_IMAGE_FORMAT = svg -DOT_NUM_THREADS = 1 EXTRACT_ALL = NO FULL_SIDEBAR = NO GENERATE_HTML = YES @@ -122,7 +121,11 @@ MACRO_EXPANSION = YES MAN_OUTPUT = man MARKDOWN_ID_STYLE = GITHUB MARKDOWN_SUPPORT = YES -NUM_PROC_THREADS = 1 +# If DOXYCONFIG_THREADS is not set in the environment, both DOT_NUM_THREADS and +# NUM_PROC_THREADS will be set to blank. A blank value for either is equivalent +# to the value of 0, i.e., multithreading will be used. +DOT_NUM_THREADS = $(DOXYCONFIG_THREADS) +NUM_PROC_THREADS = $(DOXYCONFIG_THREADS) PROJECT_NUMBER = $(READTHEDOCS_VERSION) OUTPUT_DIRECTORY = $(READTHEDOCS_OUTPUT) RECURSIVE = YES