Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem2/cmake/DocumentationTarget.cmake @ 2633

Last change on this file since 2633 was 2633, checked in by rgrieder, 15 years ago

Added documentation target. Surprisingly worked on my box just like that. I had to limit the input files to /src (source and binary tree) though, or Doxygen would have created for all the dependencies as well (boost, ogre, etc.) because of the dependencies folder.

Note: This is all just copy & paste from the CMake forum. I haven't had a look at it.
Somebody will have to merge our own Doxyfile with the new one.

  • Property svn:eol-style set to native
File size: 5.3 KB
Line 
1# -helper macro to add a "doc" target with CMake build system.
2# and configure doxy.config.in to doxy.config
3#
4# target "doc" allows building the documentation with doxygen/dot on WIN32 and Linux
5# Creates .chm windows help file if MS HTML help workshop
6# (available from http://msdn.microsoft.com/workshop/author/htmlhelp)
7# is installed with its DLLs in PATH.
8#
9#
10# Please note, that the tools, e.g.:
11# doxygen, dot, latex, dvips, makeindex, gswin32, etc.
12# must be in path.
13#
14# Note about Visual Studio Projects:
15# MSVS hast its own path environment which may differ from the shell.
16# See "Menu Tools/Options/Projects/VC++ Directories" in VS 7.1
17#
18# author Jan Woetzel 2004-2006
19# www.mip.informatik.uni-kiel.de/~jw
20
21
22FIND_PACKAGE(Doxygen)
23
24IF (DOXYGEN_FOUND)
25
26  # click+jump in Emacs and Visual Studio (for doxy.config) (jw)
27  IF    (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
28    SET(DOXY_WARN_FORMAT "\"$file($line) : $text \"")
29  ELSE  (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
30    SET(DOXY_WARN_FORMAT "\"$file:$line: $text \"")
31  ENDIF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
32 
33  # we need latex for doxygen because of the formulas
34  FIND_PACKAGE(LATEX)
35  IF    (NOT LATEX_COMPILER)
36    MESSAGE(STATUS "latex command LATEX_COMPILER not found but usually required. You will probably get warnings and user inetraction on doxy run.")
37  ENDIF (NOT LATEX_COMPILER)
38  IF    (NOT MAKEINDEX_COMPILER)
39    MESSAGE(STATUS "makeindex command MAKEINDEX_COMPILER not found but usually required.")
40  ENDIF (NOT MAKEINDEX_COMPILER)
41  IF    (NOT DVIPS_CONVERTER)
42    MESSAGE(STATUS "dvips command DVIPS_CONVERTER not found but usually required.")
43  ENDIF (NOT DVIPS_CONVERTER)
44 
45  IF   (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
46    MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in --> ${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
47    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in 
48      ${CMAKE_CURRENT_BINARY_DIR}/doxy.config
49      @ONLY )
50    # use (configured) doxy.config from (out of place) BUILD tree:
51    SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
52  ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
53    # use static hand-edited doxy.config from SOURCE tree:
54    SET(DOXY_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
55    IF   (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
56      MESSAGE(STATUS "WARNING: using existing ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config instead of configuring from doxy.config.in file.")
57    ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
58      IF   (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
59        # using template doxy.config.in
60        MESSAGE(STATUS "configured ${CMAKE_CMAKE_MODULE_PATH}/doxy.config.in --> ${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
61        CONFIGURE_FILE(${CMAKE_MODULE_PATH}/doxy.config.in 
62          ${CMAKE_CURRENT_BINARY_DIR}/doxy.config
63          @ONLY )
64        SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
65      ELSE (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
66        # failed completely...
67        MESSAGE(SEND_ERROR "Please create ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in (or doxy.config as fallback)")
68      ENDIF(EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
69
70    ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
71  ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
72 
73  ADD_CUSTOM_TARGET(doc ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG})
74 
75  # create a windows help .chm file using hhc.exe
76  # HTMLHelp DLL must be in path!
77  # fallback: use hhw.exe interactively
78  IF    (WIN32)
79    FIND_PACKAGE(HTMLHelp)
80    IF   (HTML_HELP_COMPILER)     
81      SET (TMP "${CMAKE_CURRENT_BINARY_DIR}\\Doc\\html\\index.hhp")
82      STRING(REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} )
83      # MESSAGE(SEND_ERROR "DBG  HHP_FILE=${HHP_FILE}")
84      ADD_CUSTOM_TARGET(winhelp ${HTML_HELP_COMPILER} ${HHP_FILE})
85      ADD_DEPENDENCIES (winhelp doc)
86     
87      IF (NOT TARGET_DOC_SKIP_INSTALL)
88      # install windows help?
89      # determine useful name for output file
90      # should be project and version unique to allow installing
91      # multiple projects into one global directory     
92      IF   (EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
93        IF   (PROJECT_NAME)
94          SET(OUT "${PROJECT_NAME}")
95        ELSE (PROJECT_NAME)
96          SET(OUT "Documentation") # default
97        ENDIF(PROJECT_NAME)
98        IF   (${PROJECT_NAME}_VERSION_MAJOR)
99          SET(OUT "${OUT}-${${PROJECT_NAME}_VERSION_MAJOR}")
100          IF   (${PROJECT_NAME}_VERSION_MINOR)
101            SET(OUT  "${OUT}.${${PROJECT_NAME}_VERSION_MINOR}")
102            IF   (${PROJECT_NAME}_VERSION_PATCH)
103              SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_PATCH}")     
104            ENDIF(${PROJECT_NAME}_VERSION_PATCH)
105          ENDIF(${PROJECT_NAME}_VERSION_MINOR)
106        ENDIF(${PROJECT_NAME}_VERSION_MAJOR)
107        # keep suffix
108        SET(OUT  "${OUT}.chm")
109       
110        #MESSAGE("DBG ${PROJECT_BINARY_DIR}/Doc/html/index.chm \n${OUT}")
111        # create target used by install and package commands
112        INSTALL(FILES "${PROJECT_BINARY_DIR}/Doc/html/index.chm"
113          DESTINATION "doc"
114          RENAME "${OUT}"
115        )
116      ENDIF(EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
117      ENDIF(NOT TARGET_DOC_SKIP_INSTALL)
118
119    ENDIF(HTML_HELP_COMPILER)
120    # MESSAGE(SEND_ERROR "HTML_HELP_COMPILER=${HTML_HELP_COMPILER}")
121  ENDIF (WIN32) 
122ENDIF(DOXYGEN_FOUND)
Note: See TracBrowser for help on using the repository browser.