summaryrefslogtreecommitdiff
path: root/docs/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/CMakeLists.txt')
-rw-r--r--docs/CMakeLists.txt73
1 files changed, 73 insertions, 0 deletions
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
new file mode 100644
index 0000000..e15db13
--- /dev/null
+++ b/docs/CMakeLists.txt
@@ -0,0 +1,73 @@
+
+###############################################################################
+### Create Doc Targets ###
+
+message(STATUS "Create sphinx conf.py from conf.py.in")
+configure_file(${CMAKE_SOURCE_DIR}/docs/conf.py.in
+ ${CMAKE_BINARY_DIR}/docs/conf.py @ONLY)
+
+message(STATUS "Copying doc to staging area")
+file(COPY ${CMAKE_SOURCE_DIR}/docs/ DESTINATION ${CMAKE_BINARY_DIR}/docs)
+
+message(STATUS "Copy extra doc files to staging area")
+list(APPEND DOCFILES ${CMAKE_SOURCE_DIR}/README)
+list(APPEND DOCFILES ${CMAKE_SOURCE_DIR}/INSTALL)
+list(APPEND DOCFILES ${CMAKE_SOURCE_DIR}/ChangeLog)
+list(APPEND DOCFILES ${CMAKE_SOURCE_DIR}/LICENSE)
+list(APPEND DOCFILES ${CMAKE_SOURCE_DIR}/share/nuke/ocionuke/viewer.py)
+CopyFiles(RSTDOC ${DOCFILES})
+
+message(STATUS "Extracting .rst files from C++ headers")
+ExtractRstCPP(${CMAKE_SOURCE_DIR}/export/OpenColorIO/OpenColorIO.h developers/api/OpenColorIO.rst)
+ExtractRstCPP(${CMAKE_SOURCE_DIR}/export/OpenColorIO/OpenColorTransforms.h developers/api/OpenColorTransforms.rst)
+ExtractRstCPP(${CMAKE_SOURCE_DIR}/export/OpenColorIO/OpenColorTypes.h developers/api/OpenColorTypes.rst)
+
+add_custom_target(doc ALL
+ COMMAND PYTHONPATH=${PYTHONPATH} sphinx-build -b html . ${CMAKE_CURRENT_BINARY_DIR}/build-html
+ DEPENDS
+ OpenColorIO
+ PyOpenColorIO
+ ${CMAKE_BINARY_DIR}/docs/conf.py
+ developers/api/OpenColorIO.rst
+ developers/api/OpenColorTransforms.rst
+ developers/api/OpenColorTypes.rst
+ ${RSTDOC_OUTPUT}
+ COMMENT "Building html docs"
+ SOURCES ${DOCFILES})
+
+# note: ExternalProject will not build when added to a add_custom_target this
+# works around this problem. This seems to be fixed in the cmake ^HEAD
+add_dependencies(doc Sphinx)
+
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build-html/
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/OpenColorIO/html
+ PATTERN .* EXCLUDE
+)
+
+find_package(LATEX)
+if(PDFLATEX_COMPILER)
+
+ add_custom_target(latex
+ COMMAND PYTHONPATH=${PYTHONPATH} sphinx-build -b latex . ${CMAKE_CURRENT_BINARY_DIR}/build-latex
+ DEPENDS
+ OpenColorIO
+ ${CMAKE_BINARY_DIR}/docs/conf.py
+ developers/api/OpenColorIO.rst
+ developers/api/OpenColorTransforms.rst
+ developers/api/OpenColorTypes.rst
+ ${RSTDOC_OUTPUT}
+ COMMENT "Building latex doc"
+ SOURCES ${DOCFILES})
+ add_dependencies(latex Sphinx)
+
+ add_custom_target(pdf ALL
+ COMMAND ${PDFLATEX_COMPILER} OpenColorIO.tex
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build-latex
+ COMMENT "Building pdf doc"
+ SOURCES ${DOCFILES})
+ add_dependencies(pdf latex)
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/build-latex/OpenColorIO.pdf
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/OpenColorIO/)
+
+endif()