ENH: More flexible -doc and -srcDoc options using index file
[freefoam.git] / CMake / Modules / FFAddExecutableToDocIndex.cmake
blobe4b28d794d43223503baf100a918c6fb95a49776
1 #-------------------------------------------------------------------------------
2 #               ______                _     ____          __  __
3 #              |  ____|             _| |_  / __ \   /\   |  \/  |
4 #              | |__ _ __ ___  ___ /     \| |  | | /  \  | \  / |
5 #              |  __| '__/ _ \/ _ ( (| |) ) |  | |/ /\ \ | |\/| |
6 #              | |  | | |  __/  __/\_   _/| |__| / ____ \| |  | |
7 #              |_|  |_|  \___|\___|  |_|   \____/_/    \_\_|  |_|
9 #                   FreeFOAM: The Cross-Platform CFD Toolkit
11 # Copyright (C) 2008-2009 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 # - Create a documentation index file
34 # CAUTION: Include this file only once!
36 # To add an exeutable to the index, use:
37 #  FF_ADD_EXECUTABLE_TO_DOC_INDEX( TARGET1 [TARGET2...] )
39 #  TARGET1... The executable targets to add to the doc index
41 # DO NOT call this function after you called
42 # FF_WRITE_DOC_INDEX, it won't have any effect!
44 # At the very end of your "master"-CMakeLists file, call:
45 #  FF_WRITE_DOC_INDEX()
46 # This will create
47 #  ${CMAKE_BINARY_DIR}/data/DoxyDocIndex.in
48 #  ${CMAKE_BINARY_DIR}/data/DoxyDocIndex
49 #  ${CMAKE_BINARY_DIR}/InstallFiles/data/DoxyDocIndex
51 # remove the list of documented apps from the cache
52 #TODO use UNSET once it is available in mainstream distros
53 set( __FF_ADD_EXECUTABLE_TO_DOC_INDEX_targets
54   CACHE INTERNAL "PURGED" FORCE
55   )
57 function( FF_ADD_EXECUTABLE_TO_DOC_INDEX )
58   set( files )
59   foreach( f ${ARGN} )
60     list( APPEND files "${f}_8C.html" "${f}_8C-source.html" )
61   endforeach( f )
62   set( __FF_ADD_EXECUTABLE_TO_DOC_INDEX_targets
63     ${__FF_ADD_EXECUTABLE_TO_DOC_INDEX_targets} ${files}
64     CACHE INTERNAL "Files to include in the documentation index"
65     FORCE
66     )
67 endfunction( FF_ADD_EXECUTABLE_TO_DOC_INDEX )
69 include( FFConfigureFiles )
71 function( FF_WRITE_DOC_INDEX )
72   # construct the list of files
73   string( REPLACE ";" "\"\n    \"" tmp "    \"${__FF_ADD_EXECUTABLE_TO_DOC_INDEX_targets}\"" )
74   # get the version string right
75   string( LENGTH ${FF_VERSION_FULL} verlength )
76   set( verstr "                                                " )
77   math( EXPR verspacelength "48-${verlength}" )
78   string( SUBSTRING "${verstr}" 0 ${verspacelength} verstr )
79   set( verstr "${FF_VERSION_FULL}${verstr}" )
80   # write the doc index file
81   file( WRITE ${CMAKE_BINARY_DIR}/data/DoxyDocIndex.in
82 "/*--------------------------------*- C++ -*----------------------------------*\\
83 |               ______                _     ____          __  __              |
84 |              |  ____|             _| |_  / __ \\   /\\   |  \\/  |             |
85 |              | |__ _ __ ___  ___ /     \\| |  | | /  \\  | \\  / |             |
86 |              |  __| '__/ _ \\/ _ ( (| |) ) |  | |/ /\\ \\ | |\\/| |             |
87 |              | |  | | |  __/  __/\\_   _/| |__| / ____ \\| |  | |             |
88 |              |_|  |_|  \\___|\\___|  |_|   \\____/_/    \\_\\_|  |_|             |
89 |                                                                             |
90 |                   FreeFOAM: The Cross-Platform CFD Toolkit                  |
91 |                   Version:  ${verstr}|
92 |                   Web:      http://freefoam.sourceforge.net                 |
93 \\*---------------------------------------------------------------------------*/
94 FoamFile
96 version     2.0;
97 format      ascii;
98 class       dictionary;
99 object      docIndex;
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 docDir \"@FF_DOC_DIR@/Doxygen/html\";
105 docFiles (
106 ${tmp}
109 // ********************* vim: set ft=cpp sw=4 sts=4 et: ******************** //
111     )
113   # annoying duplication of ff_configure_files, but that one can't be used
114   # because it would put things in
115   # ${CMAKE_BINARY_DIR}/data/${CMAKE_BINARY_DIR}/DoxyDocIndex and
116   # ${CMAKE_BINARY_DIR}/InstallFiles/data/${CMAKE_BINARY_DIR}/DoxyDocIndex.
118   # binary tree
119   set( FF_DOC_DIR "http://freefoam.sf.net/doc" )
120   set( FF_LOCAL_DOC_DIR ${CMAKE_BINARY_DIR}/doc )
121   if( FF_USE_LOCAL_DOXYGEN_DOCS )
122     set( FF_DOC_DIR ${FF_LOCAL_DOC_DIR} )
123   endif( FF_USE_LOCAL_DOXYGEN_DOCS )
124   configure_file( ${CMAKE_BINARY_DIR}/data/DoxyDocIndex.in
125     ${CMAKE_BINARY_DIR}/data/DoxyDocIndex @ONLY )
127   # install tree
128   set( FF_LOCAL_DOC_DIR ${FF_INSTALL_DOC_PATH} )
129   if( FF_USE_LOCAL_DOXYGEN_DOCS )
130     set( FF_DOC_DIR ${FF_LOCAL_DOC_DIR} )
131   endif( FF_USE_LOCAL_DOXYGEN_DOCS )
132   configure_file( ${CMAKE_BINARY_DIR}/data/DoxyDocIndex.in
133     ${CMAKE_BINARY_DIR}/InstallFiles/data/DoxyDocIndex @ONLY )
135 endfunction( FF_WRITE_DOC_INDEX )
137 # ------------------------- vim: set ft=cmake sw=2 sts=2 et: --------------- end-of-file