c72da7bb6ebf5ba3c21003c1f0f850e072058d74
[alexxy/gromacs.git] / manual / CMakeLists.txt
1
2 if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
3     # UseLATEX.cmake does not work with an in-source build
4     message(STATUS "Cannot build the manual when building in the source directory")
5     set(MANUAL_BUILD_IS_POSSIBLE OFF)
6 else()
7     INCLUDE(UseLATEX.cmake)
8
9     if(NOT PDFLATEX_COMPILER OR NOT IMAGEMAGICK_CONVERT)
10         # No pdflatex was found, so don't build the manual.
11         message(STATUS "A required dependency of the manual (pdflatex, ImageMagick's convert) was not found, so the manual build will not be available")
12         set(MANUAL_BUILD_IS_POSSIBLE OFF)
13
14         # TODO Later, identify other dependencies like bibtex,
15         # make_index, date, some graphics conversion program,
16         # etc. Perhaps patch UseLATEX.cmake and contribute upstream.
17     else()
18         set(MANUAL_BUILD_IS_POSSIBLE ON)
19     endif()
20 endif()
21
22 if(MANUAL_BUILD_IS_POSSIBLE)
23     LATEX_GET_OUTPUT_PATH(output_dir)
24
25     # Avoid generating a global "html" target that clashes with the
26     # html target from program generaion of help text in share/html.
27     set(LATEX2HTML_CONVERTER off)
28
29     # This helps make the index look decent.
30     set(MAKEINDEX_COMPILER_FLAGS -s ${CMAKE_CURRENT_SOURCE_DIR}/hfill.ist)
31     # UseLATEX.cmake is hacked to call Anton Feenstra's subindex script
32     # to improve the index generation. Don't replace UseLATEX.cmake
33     # blindly from upstream!
34
35     # Here follows various custom CMake "commands" that call our various
36     # GROMACS helper scripts to make bits of the manual from the installed
37     # binaries and/or source distribution, as appropriate.
38     #
39     # Only files that can be built should be listed in DEPENDS. Makefile
40     # rules are generated for those files.
41     #
42     # The .mdp options section is now intended to be built directly
43     # from a GROMACS source directory. This facilitates drafting
44     # updates in that HTML file without copying files by hand.
45
46     ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/mdp_opt.tex
47         COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mkmdp ARGS ${CMAKE_SOURCE_DIR}/share/html
48         DEPENDS mkmdp ${CMAKE_SOURCE_DIR}/share/html/online/mdp_opt.html
49         )
50
51     ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/proglist.tex
52         COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mkproglist ARGS ${CMAKE_SOURCE_DIR}/admin/programs.txt
53         DEPENDS mkproglist ${CMAKE_SOURCE_DIR}/admin/programs.txt
54         )
55
56     # Finally, the command to build the manual.
57
58     ADD_LATEX_DOCUMENT(gromacs.tex
59         # Normal LaTeX \included files
60         INPUTS algorithms.tex  defunits.tex    implement.tex  macros.tex     special.tex
61         analyse.tex     files.tex       gmxpar.tex     install.tex    topology.tex
62         averages.tex    forcefield.tex  gromacs.tex    intro.tex      programs.tex
63
64         # CMake does variable replacement in these files
65         CONFIGURE macros.tex
66
67         # These files we're responsible for creating in the
68         # add_custom_targets() above. They should not be in the git
69         # repository, or its directory, or the dependencies will not work
70         # properly.
71         DEPENDS proglist.tex mdp_opt.tex
72
73         BIBFILES monster.bib unpubl.bib
74         IMAGE_DIRS plots
75         DEFAULT_PDF
76         USE_INDEX
77         )
78 endif()
79
80 if(MANUAL_BUILD_IS_POSSIBLE)
81     # An explicit "make manual" will still be required for the manual
82     # to be built.
83     add_custom_target(manual DEPENDS pdf)
84 else()
85     # TODO Arrange for the "make manual" target to explain that this can't
86     # be done
87 endif()