CMakeLists.txt 5.39 KB
Newer Older
Simon Spannagel's avatar
Simon Spannagel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#############################################
# Doxygen target to generate API reference  #
#############################################

FIND_PACKAGE(Doxygen)

IF(DOXYGEN_FOUND)
    CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/doc/reference/Doxyfile.in ${CMAKE_BINARY_DIR}/reference/Doxyfile @ONLY)
    ADD_CUSTOM_TARGET(reference
        ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/reference/Doxyfile
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/reference
        COMMENT "Generating API documentation with Doxygen"
        VERBATIM
        )
ENDIF(DOXYGEN_FOUND)

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
###############################################
# LaTeX target to compile the PDF user manual #
###############################################

# Information and the manual on the UseLATEX.cmake package can be found here
# http://www.cmake.org/Wiki/CMakeUserUseLATEX

FIND_PACKAGE(LATEX)

# Only add target if we have LaTeX
IF(LATEX_COMPILER)
    MESSAGE(STATUS "Found LaTeX compiler.")
    SET(LATEX_COMPILER_FLAGS "-shell-escape" "-interaction nonstopmode" "-halt-on-error" "-file-line-error" CACHE STRING "Flags passed to latex.")
    INCLUDE(${CMAKE_SOURCE_DIR}/cmake/LATEX.cmake)

    SET(HTLATEX_COMPILER_TEX4HT_FLAGS "usermanual/html/corryvreckan,charset=utf-8" CACHE STRING "Flags passed to Tex4HT" FORCE)
    SET(HTLATEX_COMPILER_TEX4HT_POSTPROCESSOR_FLAGS "-utf8 -cunihtf" CACHE STRING "Flags passed to the postprocessor of Tex4HT" FORCE)

35
36
37
38
39
    # Markdown files that should be included in the manual relative to the root of the repository
    SET(DOC_README_FILES
            jobsub/README.md
    )

40
41
42
    # Check for pandoc for markdown conversion
    INCLUDE(${CMAKE_SOURCE_DIR}/cmake/PANDOC.cmake)
    IF(PANDOC_EXECUTABLE)
43
44
45
        # Loop through all modules and fetch their README
        SET(module_dir ${CMAKE_SOURCE_DIR}/src/modules)
        FILE(GLOB subdirs RELATIVE ${module_dir} ${module_dir}/*)
46
        FOREACH(subdir ${subdirs})
47
            IF(EXISTS ${module_dir}/${subdir}/README.md AND NOT ${subdir} STREQUAL "Dummy")
48
                ADD_PANDOC_DOCUMENT(
49
50
51
                    ${CMAKE_BINARY_DIR}/usermanual/modules/${subdir}.tex
                    SOURCES              ${module_dir}/${subdir}/README.md
                    PRODUCT_DIRECTORY    usermanual/modules/
52
53
54
                    PANDOC_DIRECTIVES    -t latex --listings --biblatex
                    NO_EXPORT_PRODUCT
                )
55
                SET(module_tex_files ${module_tex_files} ${CMAKE_BINARY_DIR}/usermanual/modules/${subdir}.tex)
56
57
            ENDIF()
        ENDFOREACH()
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

        # Generate other tex files from README we need and put them in the MD folder of the user manual
        SET(other_tex_files "")
        FOREACH(doc_readme_file ${DOC_README_FILES})
            GET_FILENAME_COMPONENT(readme_full_dir ${doc_readme_file} DIRECTORY)
            GET_FILENAME_COMPONENT(readme_parent_dir ${readme_full_dir} DIRECTORY)
            GET_FILENAME_COMPONENT(readme_dir_name ${readme_full_dir} NAME)

            ADD_PANDOC_DOCUMENT(
                ${CMAKE_BINARY_DIR}/usermanual/md/${readme_parent_dir}/${readme_dir_name}.tex
                SOURCES              ${CMAKE_SOURCE_DIR}/${doc_readme_file}
                PRODUCT_DIRECTORY    usermanual/md/${readme_parent_dir}/
                PANDOC_DIRECTIVES    -t latex --listings --biblatex
                NO_EXPORT_PRODUCT
            )

            SET(other_tex_files ${other_tex_files} ${CMAKE_BINARY_DIR}/usermanual/md/${readme_parent_dir}/${readme_dir_name}.tex)
        ENDFOREACH()
76
    ELSE()
77
        SET(module_tex_files)
78
        SET(other_tex_files "")
79
80
81
82
        MESSAGE(WARNING "No pandoc command, cannot add Markdown documentation to user manual")
    ENDIF()

    # Build array of LaTex files to add to the documentation
83
84
85
86
87
    LIST(LENGTH module_tex_files NUM_MODULES)
    MESSAGE(STATUS "Manual: adding ${NUM_MODULES} module descriptions")
    FOREACH(module_tex_file ${module_tex_files})
        IF(NOT CORRYVRECKAN_MODULE_FILES)
            SET(CORRYVRECKAN_MODULE_FILES "{${module_tex_file}")
88
        ELSE()
89
            SET(CORRYVRECKAN_MODULE_FILES "${CORRYVRECKAN_MODULE_FILES},${module_tex_file}")
90
91
        ENDIF()
    ENDFOREACH()
92
93
    IF(CORRYVRECKAN_MODULE_FILES)
        SET(CORRYVRECKAN_MODULE_FILES "${CORRYVRECKAN_MODULE_FILES}}")
94
    ELSE()
95
        SET(CORRYVRECKAN_MODULE_FILES "")
96
97
98
99
100
101
102
    ENDIF()

    # Check if we have biber and do not build if not
    IF(BIBER_COMPILER)
        SET(LATEX_OUTPUT_PATH ${CMAKE_BINARY_DIR}/usermanual)
        ADD_LATEX_DOCUMENT(
            usermanual/corryvreckan-manual.tex
Simon Spannagel's avatar
Simon Spannagel committed
103
104
105
            BIBFILES
            usermanual/references.bib
            USE_BIBLATEX
106
107
108
109
            IMAGES
            logo.png
            cc-by.png
            INPUTS
Simon Spannagel's avatar
Simon Spannagel committed
110
            usermanual/chapters/introduction.tex
111
112
113
114
            usermanual/chapters/installation.tex
            usermanual/chapters/framework.tex
            usermanual/chapters/configuration.tex
            usermanual/chapters/correlation.tex
Simon Spannagel's avatar
Simon Spannagel committed
115
            usermanual/chapters/onlinemonitoring.tex
116
            usermanual/chapters/modules.tex
Simon Spannagel's avatar
Simon Spannagel committed
117
            usermanual/chapters/development.tex
118
            usermanual/chapters/tools.tex
119
120
121
122
123
            usermanual/config.tex

            CONFIGURE
            usermanual/config.tex
            EXCLUDE_FROM_ALL
124
            DEPENDS ${module_tex_files} ${other_tex_files})
125
126
127
128
129
130
    ELSE()
        MESSAGE(WARNING "No biber command, cannot compile user manual.")
    ENDIF()
ELSE(LATEX_COMPILER)
    MESSAGE(WARNING "No LaTeX found, cannot compile user manual.")
ENDIF(LATEX_COMPILER)