717cf3c3875343d4693746128f05bd2b3b8419ae
[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     # This helps make the index look decent.
26     set(MAKEINDEX_COMPILER_FLAGS -s ${CMAKE_CURRENT_SOURCE_DIR}/hfill.ist)
27     # UseLATEX.cmake is hacked to call Anton Feenstra's subindex script
28     # to improve the index generation. Don't replace UseLATEX.cmake
29     # blindly from upstream!
30
31     # Here follows various custom CMake "commands" that call our various
32     # GROMACS helper scripts to make bits of the manual from the installed
33     # binaries and/or source distribution, as appropriate.
34     #
35     # Only files that can be built should be listed in DEPENDS. Makefile
36     # rules are generated for those files.
37     #
38     # The .mdp options section is now intended to be built directly
39     # from a GROMACS source directory. This facilitates drafting
40     # updates in that HTML file without copying files by hand.
41
42     ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/mdp_opt.tex
43         COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mkmdp ARGS ${CMAKE_SOURCE_DIR}/share/html
44         DEPENDS mkmdp ${CMAKE_SOURCE_DIR}/share/html/online/mdp_opt.html
45         )
46
47     ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/proglist.tex
48         COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mkproglist ARGS ${CMAKE_SOURCE_DIR}/admin/programs.txt
49         DEPENDS mkproglist ${CMAKE_SOURCE_DIR}/admin/programs.txt
50         )
51
52     # Finally, the command to build the manual.
53
54     ADD_LATEX_DOCUMENT(gromacs.tex
55         # Normal LaTeX \included files
56         INPUTS algorithms.tex  defunits.tex    implement.tex  macros.tex     special.tex
57         analyse.tex     files.tex       gmxpar.tex     install.tex    topology.tex
58         averages.tex    forcefield.tex  gromacs.tex    intro.tex      programs.tex
59
60         # CMake does variable replacement in these files
61         CONFIGURE macros.tex
62
63         # These files we're responsible for creating in the
64         # add_custom_targets() above. They should not be in the git
65         # repository, or its directory, or the dependencies will not work
66         # properly.
67         DEPENDS proglist.tex mdp_opt.tex
68
69         BIBFILES monster.bib unpubl.bib
70         IMAGE_DIRS plots
71         DEFAULT_PDF
72         USE_INDEX
73         )
74 endif()
75
76 if(MANUAL_BUILD_IS_POSSIBLE)
77     # An explicit "make manual" will still be required for the manual
78     # to be built.
79     add_custom_target(manual DEPENDS pdf)
80 else()
81     # TODO Arrange for the "make manual" target to explain that this can't
82     # be done
83 endif()