]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Support building liblzma API docs using Doxygen
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 27 Apr 2024 17:42:00 +0000 (20:42 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 30 Apr 2024 14:09:08 +0000 (17:09 +0300)
This is disabled by default to match the default in Autotools.
Use -DUSE_DOXYGEN=ON to enable Doxygen usage.

This uses the update-doxygen script, thus this is under if(UNIX)
although Doxygen itself can run on Windows too.

CMakeLists.txt

index ac6b5803cbbba271a743b61b0f7113e5cc3864ea..690a3ae1caa13d4ac888ec373ac7cda2b929256d 100644 (file)
 #   - To get translated man pages, run po4a/update-po which requires
 #     the po4a tool. The build works without this step too.
 #
-#   - To get Doxygen-generated liblzma API docs in HTML format,
-#     run doxygen/update-doxygen which requires the doxygen tool.
-#     The build works without this step too.
-#
 # This file provides the following installation components (if you only
 # need liblzma, install only its components!):
 #   - liblzma_Runtime (shared library only)
@@ -1965,12 +1961,38 @@ endif()
 # Documentation
 #############################################################################
 
-# Use OPTIONAL because doc/api might not exist. The liblzma API docs
-# can be generated by running "doxygen/update-doxygen".
-install(DIRECTORY doc/api doc/examples
+if(UNIX)
+    option(USE_DOXYGEN "Use Doxygen to generate liblzma API docs" OFF)
+
+    if (USE_DOXYGEN)
+        file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc")
+
+        add_custom_command(
+            VERBATIM
+            COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/doxygen/update-doxygen"
+            ARGS "api"
+                 "${CMAKE_CURRENT_SOURCE_DIR}"
+                 "${CMAKE_CURRENT_BINARY_DIR}/doc"
+            OUTPUT doc/api/index.html
+            DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/doxygen/update-doxygen"
+                    "${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile"
+                    ${LIBLZMA_API_HEADERS}
+        )
+
+        add_custom_target(
+            liblzma-doc-api ALL
+            DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/doc/api/index.html"
+        )
+
+        install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/api"
+                DESTINATION "${CMAKE_INSTALL_DOCDIR}"
+                COMPONENT liblzma_Documentation)
+    endif()
+endif()
+
+install(DIRECTORY doc/examples
         DESTINATION "${CMAKE_INSTALL_DOCDIR}"
-        COMPONENT liblzma_Documentation
-        OPTIONAL)
+        COMPONENT liblzma_Documentation)
 
 # GPLv2 applies to the scripts. If GNU getopt_long is used then
 # LGPLv2.1 applies to the command line tools but, using the