Unify documentation for webpage build
[alexxy/gromacs.git] / docs / install-guide / CMakeLists.txt
similarity index 59%
rename from install-guide/CMakeLists.txt
rename to docs/install-guide/CMakeLists.txt
index fb5faaa7e0e3f6dd44c2dfa71fa86478f3da098c..770240d29a791db9eef6cb9a63a8a3fce564430b 100644 (file)
@@ -43,14 +43,17 @@ endif()
 
 if(INSTALL_GUIDE_BUILD_IS_POSSIBLE)
     # Do replacement of CMake variables for version strings, etc.
+    # This defers until build time the configuration of
+    # install-guide.md, which could be faster for all the
+    # configurations that don't make the install guide even though it
+    # was possible.
     configure_file(configure-install-guide.cmake.in
         ${CMAKE_CURRENT_BINARY_DIR}/configure-install-guide.cmake
         @ONLY)
 
-    # This defers until build time the configuration of
-    # install-guide.md, which could be faster
+    # Configure the install-guide.md at build time
     add_custom_command(
-        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/install-guide.md
+        OUTPUT ${CMAKE_BINARY_DIR}/install-guide.md
         COMMAND ${CMAKE_COMMAND}
             -P ${CMAKE_CURRENT_BINARY_DIR}/configure-install-guide.cmake
         DEPENDS
@@ -60,30 +63,65 @@ if(INSTALL_GUIDE_BUILD_IS_POSSIBLE)
         VERBATIM
         )
 
-    # Make the HTML install guide
-    add_custom_command(
-        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/install-guide.html
-        COMMAND pandoc -t html -o ${CMAKE_CURRENT_BINARY_DIR}/install-guide.html install-guide.md -s --toc
-        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/install-guide.md
-        VERBATIM
-        )
-
     # Make the INSTALL file for CPack for the tarball. This gets put
     # into the tarball via the CPack rules in the top-level
     # CMakeLists.txt
     add_custom_command(
         OUTPUT final/INSTALL
         COMMAND ${CMAKE_COMMAND} -E make_directory final
-        COMMAND pandoc -t plain -o final/INSTALL install-guide.md
-        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/install-guide.md
+        COMMAND ${PANDOC_EXECUTABLE} -t plain -o final/INSTALL install-guide.md
+        DEPENDS
+            ${CMAKE_BINARY_DIR}/install-guide.md
         VERBATIM
         )
 
-    # Add a top-level target for the others to hook onto
+    # Make the single-page HTML install guide
+    add_custom_command(
+        OUTPUT ${HTML_OUTPUT_DIR}/install-guide.html
+        COMMAND
+            ${PANDOC_EXECUTABLE} install-guide.md -o ${HTML_OUTPUT_DIR}/install-guide.html -s --toc --css buttondown.css
+        DEPENDS
+            ${CMAKE_BINARY_DIR}/install-guide.md
+        VERBATIM
+        )
+
+    # Make the PDF install guide
+    add_custom_command(
+        OUTPUT ${HTML_OUTPUT_DIR}/install-guide.pdf
+        COMMAND
+            ${PANDOC_EXECUTABLE} install-guide.md -o ${HTML_OUTPUT_DIR}/install-guide.pdf -s --toc
+        DEPENDS
+            ${CMAKE_BINARY_DIR}/install-guide.md
+        VERBATIM
+        )
+
+    # Make the multi-page HTML install guide
+    #
+    # TODO This is currently disabled, because the pandoc-specific
+    # buttondown.css doesn't work with the different kind of output
+    # makeinfo produces. When we understand better how we want to
+    # do generation, decide whether we want multi-page HTML output
+    # and how to make it work well.
+    #
+    # add_custom_command(
+    #     OUTPUT ${HTML_OUTPUT_DIR}/index.html
+    #     COMMAND
+    #         ${PANDOC_EXECUTABLE} install-guide.md -o install-guide.texi -s
+    #     COMMAND
+    #         ${MAKEINFO_EXECUTABLE} install-guide.texi --html -o ${HTML_OUTPUT_DIR}/install-guide --css-ref buttondown.css
+    #     DEPENDS
+    #         ${CMAKE_BINARY_DIR}/install-guide.md
+    #     VERBATIM
+    #     )
+
+    # Add a top-level target for the webpage build to hook onto
     add_custom_target(install-guide
         DEPENDS
-           ${CMAKE_CURRENT_BINARY_DIR}/install-guide.html
-           final/INSTALL
+            final/INSTALL
+            ${HTML_OUTPUT_DIR}/install-guide.html
+            ${HTML_OUTPUT_DIR}/install-guide.pdf
         VERBATIM
         )
 endif()
+
+set(INSTALL_GUIDE_BUILD_IS_POSSIBLE ${INSTALL_GUIDE_BUILD_IS_POSSIBLE} PARENT_SCOPE)