# $Id: CMakeLists.txt,v 1.14 2006/07/12 14:53:31 ppoilbarbe Exp $
# $Name:  $
#
# Build file for CMake in order to generate the documentation.
#

OPTION(MYPROJECT_DOC_CREATE_PDF "Create PDF reference manual" ON)

OPTION(MYPROJECT_DOC_WITH_STATIC "Create documentation for static members" ON)
OPTION(MYPROJECT_DOC_WITH_PRIVATE "Create documentation for private members" ON)
OPTION(MYPROJECT_DOC_WITH_LOCAL "Create documentation for local members" ON)
OPTION(MYPROJECT_DOC_WITH_INTERNAL "Create documentation for internal features" ON)

MARK_AS_ADVANCED(
	MYPROJECT_DOC_WITH_PRIVATE
	MYPROJECT_DOC_WITH_STATIC
	MYPROJECT_DOC_WITH_LOCAL
	MYPROJECT_DOC_WITH_INTERNAL
)

# ---------------------------------
# Cmake modules needed
# ---------------------------------
FIND_PACKAGE(HTMLHelp)
FIND_PACKAGE(LATEX)

IF (HTML_HELP_COMPILER)
  SET(DOXYGEN_HTMLHELP YES)
ELSE (HTML_HELP_COMPILER)
  SET(DOXYGEN_HTMLHELP NO)
ENDIF (HTML_HELP_COMPILER)

#IF (LATEX_COMPILER OR PDFLATEX_COMPILER)
#  SET(DOXYGEN_LATEX YES)
#ELSE (LATEX_COMPILER OR PDFLATEX_COMPILER)
  SET(DOXYGEN_LATEX NO)
#ENDIF (LATEX_COMPILER OR PDFLATEX_COMPILER)

#IF (PDFLATEX_COMPILER AND MYPROJECT_DOC_CREATE_PDF)
#  SET(DOXYGEN_PDFLATEX YES)
#ELSE (PDFLATEX_COMPILER AND MYPROJECT_DOC_CREATE_PDF)
  SET(DOXYGEN_PDFLATEX NO)
#ENDIF (PDFLATEX_COMPILER AND MYPROJECT_DOC_CREATE_PDF)

IF (MYPROJECT_DOC_CREATE_PDF)
  SET(DOXYGEN_PDF_HYPERLINKS YES)
ELSE (MYPROJECT_DOC_CREATE_PDF)
  SET(DOXYGEN_PDF_HYPERLINKS NO)
ENDIF (MYPROJECT_DOC_CREATE_PDF)

IF (MYPROJECT_DOC_WITH_PRIVATE)
  SET(DOXYGEN_EXTRACT_PRIVATE YES)
ELSE (MYPROJECT_DOC_WITH_PRIVATE)
  SET(DOXYGEN_EXTRACT_PRIVATE NO)
ENDIF (MYPROJECT_DOC_WITH_PRIVATE)

IF (MYPROJECT_DOC_WITH_STATIC)
  SET(DOXYGEN_EXTRACT_STATIC YES)
ELSE (MYPROJECT_DOC_WITH_STATIC)
  SET(DOXYGEN_EXTRACT_STATIC NO)
ENDIF (MYPROJECT_DOC_WITH_STATIC)

IF (MYPROJECT_DOC_WITH_LOCAL)
  SET(DOXYGEN_EXTRACT_LOCAL YES)
ELSE (MYPROJECT_DOC_WITH_LOCAL)
  SET(DOXYGEN_EXTRACT_LOCAL NO)
ENDIF (MYPROJECT_DOC_WITH_LOCAL)

IF (MYPROJECT_DOC_WITH_INTERNAL)
  SET(DOXYGEN_EXTRACT_INTERNAL YES)
ELSE (MYPROJECT_DOC_WITH_INTERNAL)
  SET(DOXYGEN_EXTRACT_INTERNAL NO)
ENDIF (MYPROJECT_DOC_WITH_INTERNAL)

IF (DOT)
  SET(HAVE_DOT YES)
ELSE (DOT)
  SET(HAVE_DOT NO)
ENDIF (DOT)

SET(DOXYGEN_LANGUAGE "English" CACHE STRING "Language used by doxygen")
MARK_AS_ADVANCED(DOXYGEN_LANGUAGE)

SET(DOXYGEN_SOURCE_DIR
  ${lml_SOURCE_DIR}/TODO
  ${lml_SOURCE_DIR}/ChangeLog
	${lml_SOURCE_DIR}
	${lml_SOURCE_DIR}/test
)
SET(DOXYGEN_OUTPUT_DIR ${lml_SOURCE_DIR}/api-doc)
STRING(REGEX REPLACE ";" " " DOXYGEN_INPUT_LIST "${DOXYGEN_SOURCE_DIR}")

CONFIGURE_FILE(doxygen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf)
#SET(HTML_TARGET ${DOXYGEN_OUTPUT_DIR}/html/index.html)
ADD_CUSTOM_TARGET(api-doc ALL
		      ${DOXYGEN} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf
		      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf)

IF (DOXYGEN_PDFLATEX)
  ADD_CUSTOM_TARGET(api-doc-pdf ALL
		      COMMAND ${PERL_EXECUTABLE} 
				${CMAKE_CURRENT_SOURCE_DIR}/CompileLatex.pl
				"${PDFLATEX_COMPILER}"
				"${DOXYGEN_OUTPUT_DIR}/refman-latex"
				refman.tex
				refman.pdf
				"${DOXYGEN_OUTPUT_DIR}/refman.pdf"
		      DEPENDS ${HTML_TARGET})
ENDIF (DOXYGEN_PDFLATEX)

