diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e43fe21..f0904b7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,11 +59,6 @@ list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
find_package(Threads REQUIRED)
-if (GLFW_BUILD_DOCS)
- set(DOXYGEN_SKIP_DOT TRUE)
- find_package(Doxygen)
-endif()
-
#--------------------------------------------------------------------
# Report backend selection
#--------------------------------------------------------------------
@@ -134,7 +129,7 @@ if (GLFW_BUILD_TESTS)
add_subdirectory(tests)
endif()
-if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
+if (GLFW_BUILD_DOCS)
add_subdirectory(docs)
endif()
@@ -156,11 +151,6 @@ if (GLFW_INSTALL)
install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
- if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
- install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html"
- DESTINATION "${CMAKE_INSTALL_DOCDIR}")
- endif()
-
# Only generate this target if no higher-level project already has
if (NOT TARGET uninstall)
configure_file(CMake/cmake_uninstall.cmake.in
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index 79cad560..d6e9b6eb 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -31,16 +31,27 @@ foreach(file IN LISTS source_files)
string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${CMAKE_CURRENT_SOURCE_DIR}/${file}\"")
endforeach()
-configure_file(Doxyfile.in Doxyfile @ONLY)
-
-add_custom_command(OUTPUT "html/index.html"
- COMMAND "${DOXYGEN_EXECUTABLE}"
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
- MAIN_DEPENDENCY Doxyfile
- DEPENDS ${header_paths} ${source_files} ${extra_files}
- COMMENT "Generating HTML documentation"
- VERBATIM)
-
-add_custom_target(docs ALL SOURCES "html/index.html")
-set_target_properties(docs PROPERTIES FOLDER "GLFW3")
+set(DOXYGEN_SKIP_DOT TRUE)
+find_package(Doxygen)
+
+if (NOT DOXYGEN_FOUND OR DOXYGEN_VERSION VERSION_LESS "1.9.8")
+ message(STATUS "Documentation generation requires Doxygen 1.9.8 or later")
+else()
+ configure_file(Doxyfile.in Doxyfile @ONLY)
+ add_custom_command(OUTPUT "html/index.html"
+ COMMAND "${DOXYGEN_EXECUTABLE}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ MAIN_DEPENDENCY Doxyfile
+ DEPENDS ${header_paths} ${source_files} ${extra_files}
+ COMMENT "Generating HTML documentation"
+ VERBATIM)
+
+ add_custom_target(docs ALL SOURCES "html/index.html")
+ set_target_properties(docs PROPERTIES FOLDER "GLFW3")
+
+ if (GLFW_INSTALL)
+ install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html"
+ DESTINATION "${CMAKE_INSTALL_DOCDIR}")
+ endif()
+endif()
diff --git a/docs/DoxygenLayout.xml b/docs/DoxygenLayout.xml
index ab971721..66cb87fd 100644
--- a/docs/DoxygenLayout.xml
+++ b/docs/DoxygenLayout.xml
@@ -5,7 +5,7 @@
-
+