ENH: Revamped docs generation
[freefoam.git] / doc / CMakeLists.txt
blobd585109e3d0bc6f90373ada5ddc9fc78b6c48400
1 #-------------------------------------------------------------------------------
2 #               ______                _     ____          __  __
3 #              |  ____|             _| |_  / __ \   /\   |  \/  |
4 #              | |__ _ __ ___  ___ /     \| |  | | /  \  | \  / |
5 #              |  __| '__/ _ \/ _ ( (| |) ) |  | |/ /\ \ | |\/| |
6 #              | |  | | |  __/  __/\_   _/| |__| / ____ \| |  | |
7 #              |_|  |_|  \___|\___|  |_|   \____/_/    \_\_|  |_|
9 #                   FreeFOAM: The Cross-Platform CFD Toolkit
11 # Copyright (C) 2008-2011 Michael Wild <themiwi@users.sf.net>
12 #                         Gerber van der Graaf <gerber_graaf@users.sf.net>
13 #-------------------------------------------------------------------------------
14 # License
15 #   This file is part of FreeFOAM.
17 #   FreeFOAM is free software; you can redistribute it and/or modify it
18 #   under the terms of the GNU General Public License as published by the
19 #   Free Software Foundation; either version 2 of the License, or (at your
20 #   option) any later version.
22 #   FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
23 #   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 #   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 #   for more details.
27 #   You should have received a copy of the GNU General Public License
28 #   along with FreeFOAM; if not, write to the Free Software Foundation,
29 #   Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #-------------------------------------------------------------------------------
32 if(FOAM_ENABLE_XHTML_HELP OR FOAM_ENABLE_DOXYGEN_DOCS
33     OR FOAM_ENABLE_XHTML_GUIDES)
34   foam_configure_files(installImgFiles
35     COPYONLY
36     DESTDIR doc/html
37     img/FreeFOAMLogo.png
38     img/CrossPlatformToolkit.png)
40   install(FILES
41     ${installImgFiles}
42     DESTINATION ${FOAM_INSTALL_DOC_PATH}/img COMPONENT doc)
44   foam_configure_files(installCSSFiles
45     COPYONLY
46     DESTDIR doc/html
47     css/layout.css
48     css/custom.css)
49   if(FOAM_ENABLE_XHTML_HELP OR FOAM_ENABLE_XHTML_GUIDES)
50     # have asciidoc, use xhtml11.css and asciidoc-xhtml12.js from there
51     configure_file("${A2X_CONF_DIR}/stylesheets/xhtml11.css"
52       "${CMAKE_CURRENT_BINARY_DIR}/html/css/xhtml11.css" COPYONLY)
53     configure_file("${A2X_CONF_DIR}/stylesheets/docbook-xsl.css"
54       "${CMAKE_CURRENT_BINARY_DIR}/html/css/docbook-xsl.css" COPYONLY)
55     set(installXHTMLCSSFiles
56       "${CMAKE_CURRENT_BINARY_DIR}/html/css/xhtml11.css"
57       "${CMAKE_CURRENT_BINARY_DIR}/html/css/docbook-xsl.css")
58     configure_file("${A2X_CONF_DIR}/javascripts/asciidoc-xhtml11.js"
59       "${CMAKE_CURRENT_BINARY_DIR}/html/js/asciidoc-xhtml11.js" COPYONLY)
60     set(installXHTMLJavaScriptFiles
61       "${CMAKE_CURRENT_BINARY_DIR}/html/js/asciidoc-xhtml11.js")
62   else()
63     # otherwise use our own
64     foam_configure_files(installXHTMLCSSFiles
65       COPYONLY
66       DESTDIR doc/html
67       css/xhtml11.css
68       css/docbook-xsl.css)
69     foam_configure_files(installXHTMLJavaScriptFiles
70       COPYONLY
71       DESTDIR doc/html
72       js/asciidoc-xhtml11.js)
73   endif()
75   install(FILES ${installCSSFiles} ${installXHTMLCSSFiles}
76     DESTINATION ${FOAM_INSTALL_DOC_PATH}/css COMPONENT doc)
77   install(FILES ${installXHTMLJavaScriptFiles}
78     DESTINATION  ${FOAM_INSTALL_DOC_PATH}/js COMPONENT doc)
79 endif()
81 if(FOAM_ENABLE_XHTML_HELP OR FOAM_ENABLE_XHTML_GUIDES)
82   set(opts
83     -f "${CMAKE_BINARY_DIR}/data/asciidoc/html.conf"
84     -a toc
85     -a linkcss
86     -a "data-uri!"
87     -a stylesdir=css
88     -a foam-stylesdir=css
89     -a scriptsdir=js
90     -a foam-scriptsdir=js
91     -a imagesdir=img
92     -a rel-doc=.
93     -a docs-only)
94   if(FOAM_DOCS_FOR_SF)
95     list(APPEND opts -a foam-doc-for_sf)
96   endif()
97   if(FOAM_ENABLE_XHTML_GUIDES)
98     list(APPEND opts -a foam-have-ug)
99   endif()
100   if(FOAM_ENABLE_XHTML_HELP)
101     list(APPEND opts -a foam-have-man)
102   endif()
103   if(FOAM_ENABLE_DOXYGEN_DOCS)
104     list(APPEND opts -a foam-have-doxy)
105   endif()
106   set(pkgdocs)
107   foreach(f ChangeLog COPYING INSTALL README ReleaseNotes)
108     set(o "${CMAKE_CURRENT_BINARY_DIR}/html/${f}.html")
109     add_custom_command(OUTPUT "${o}"
110       COMMAND "${ASCIIDOC_EXECUTABLE}"
111         ${opts} -o "${o}" "${CMAKE_SOURCE_DIR}/${f}"
112       DEPENDS "${CMAKE_SOURCE_DIR}/${f}"
113         "${CMAKE_BINARY_DIR}/data/asciidoc/html.conf"
114       COMMENT "Generating ${f}.html"
115       VERBATIM)
116     list(APPEND pkgdocs "${o}")
117   endforeach()
118   add_custom_target(pkgdocs DEPENDS ${pkgdocs})
119   add_dependencies(doc pkgdocs)
120   install(FILES ${pkgdocs}
121     DESTINATION ${FOAM_INSTALL_DOC_PATH} COMPONENT doc)
122 endif()
124 add_subdirectory(man/manSource)
126 if(FOAM_ENABLE_DOXYGEN_DOCS)
127   add_subdirectory(Doxygen)
128 endif()
130 if(FOAM_ENABLE_XHTML_GUIDES AND FOAM_ENABLE_MATHJAX)
131   configure_file(js/MathJaxMacros.js
132     "${CMAKE_CURRENT_BINARY_DIR}/html/js/MathJaxMacros.js" COPYONLY)
133   install(FILES "${CMAKE_CURRENT_BINARY_DIR}/html/js/MathJaxMacros.js"
134     DESTINATION "${FOAM_INSTALL_DOC_PATH}/js" COMPONENT doc)
135 endif()
137 if(FOAM_GUIDES_FORMATS)
138   add_subdirectory(UserGuide)
139 endif()
141 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file