PageRenderTime 71ms CodeModel.GetById 63ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/docs/CMakeLists.txt

Relevant Search: With Applications for Solr and Elasticsearch

For more in depth reading about search, ranking and generally everything you could ever want to know about how lucene, elasticsearch or solr work under the hood I highly suggest this book. Easily one of the most interesting technical books I have read in a long time. If you are tasked with solving search relevance problems even if not in Solr or Elasticsearch it should be your first reference. Amazon Affiliate Link
http://github.com/imageworks/OpenColorIO
CMake | 186 lines | 127 code | 30 blank | 29 comment | 8 complexity | 0882fbab44ce1f0f2f29595d03ae61f4 MD5 | raw file
  1# SPDX-License-Identifier: BSD-3-Clause
  2# Copyright Contributors to the OpenColorIO Project.
  3
  4###############################################################################
  5### Python ###
  6find_package(PythonInterp 2.7 REQUIRED)
  7if(NOT OCIO_BUILD_PYTHON)
  8    message(FATAL_ERROR "Doc generation requires that the python bindings be built")
  9endif()
 10
 11###############################################################################
 12### External Python dependencies ###
 13
 14include(FindPythonPackage)
 15
 16# Sphinx
 17# https://pypi.python.org/pypi/Sphinx
 18set(SPHINX_MIN_VERSION 1.8.5)
 19find_package(Sphinx ${SPHINX_MIN_VERSION} REQUIRED)
 20if(NOT SPHINX_FOUND)
 21    message(FATAL_ERROR "Doc generation requires Sphinx")
 22endif()
 23
 24###############################################################################
 25### Setup PYTHONPATH ###
 26
 27# Override PYTHONPATH prior to running Sphinx. This makes the PyOpenColorIO
 28# build available, prioritizes ext/ installed Python dependencies, and
 29# propagates the system PYTHONPATH.
 30if(WIN32)
 31    # Use Windows path separators since this is being passed through to cmd
 32    file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} WIN_BINARY_DIR)
 33
 34    set(DLL_PATH "${WIN_BINARY_DIR}\\src\\OpenColorIO")
 35    if(MSVC_IDE)
 36        set(DLL_PATH "${DLL_PATH}\\${CMAKE_BUILD_TYPE}")
 37    endif()
 38
 39    string(CONCAT PATH_SET
 40        "PATH="
 41        "${DLL_PATH}"
 42        "\\\\;"
 43        "%PATH%"
 44    )
 45
 46    set(PYD_PATH "${WIN_BINARY_DIR}\\src\\bindings\\python")
 47    if(MSVC_IDE)
 48        set(PYD_PATH "${PYD_PATH}\\${CMAKE_BUILD_TYPE}")
 49    endif()
 50
 51    string(CONCAT PYTHONPATH_SET
 52        "PYTHONPATH="
 53        "${PYD_PATH}"
 54        "\\\\;"
 55        "${WIN_BINARY_DIR}\\ext\\dist\\lib\\site-packages"
 56        "\\\\;"
 57        "%PYTHONPATH%"
 58    )
 59    # Mimic *nix:
 60    #   '> PYTHONPATH=XXX CMD'
 61    # on Windows with:
 62    #   '> set PYTHONPATH=XXX \n call CMD'
 63    # '\n' is here because '\\&' does not work.
 64    set(PYT_PRE_CMD set ${PATH_SET} "\n" set ${PYTHONPATH_SET} "\n" call)
 65
 66else()
 67    set(PYTHON_VARIANT "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
 68    string(CONCAT PYT_PRE_CMD
 69        "PYTHONPATH="
 70        "${CMAKE_BINARY_DIR}/src/bindings/python"
 71        ":"
 72        "${CMAKE_BINARY_DIR}/ext/dist/lib${LIB_SUFFIX}/python${PYTHON_VARIANT}/site-packages"
 73        ":"
 74        "$ENV{PYTHONPATH}"
 75    )
 76endif()
 77
 78###############################################################################
 79### Copy templates to build area ###
 80
 81message(STATUS "Create sphinx conf.py from conf.py.in")
 82configure_file(conf.py.in ${CMAKE_BINARY_DIR}/docs/conf.py @ONLY)
 83
 84file(GLOB_RECURSE DOC_SOURCES "${CMAKE_SOURCE_DIR}/docs/*")
 85list(APPEND DOC_SOURCES
 86    ${CMAKE_SOURCE_DIR}/README.md
 87    ${CMAKE_SOURCE_DIR}/INSTALL.md
 88    ${CMAKE_SOURCE_DIR}/CHANGELOG.md
 89    ${CMAKE_SOURCE_DIR}/LICENSE
 90)
 91if(OCIO_BUILD_NUKE)
 92    list(APPEND DOC_SOURCES ${CMAKE_SOURCE_DIR}/share/nuke/ocionuke/viewer.py)
 93endif()
 94
 95add_custom_target(doc_copy
 96    COMMENT "Copying doc files to staging area"
 97)
 98
 99foreach(f ${DOC_SOURCES})
100    string(REGEX REPLACE "^${CMAKE_SOURCE_DIR}/" "" relpath ${f})
101    string(REGEX REPLACE "[/. ]" "_" tgtname ${relpath})
102    string(REGEX MATCH "^docs" IN_DOCS ${relpath})
103
104    set(SRC_PATH ${CMAKE_SOURCE_DIR}/${relpath})
105    set(DST_PATH ${CMAKE_BINARY_DIR}/${relpath})
106    if(NOT IN_DOCS)
107        get_filename_component(F_NAME ${relpath} NAME)
108        set(DST_PATH "${CMAKE_BINARY_DIR}/docs/${F_NAME}")
109    endif()
110
111    add_custom_command(OUTPUT ${DST_PATH}
112        COMMAND ${CMAKE_COMMAND} -E copy ${SRC_PATH} ${DST_PATH}
113        DEPENDS ${SRC_PATH}
114    )
115    add_custom_target("copy_${tgtname}" DEPENDS ${DST_PATH})
116    add_dependencies(doc_copy "copy_${tgtname}")
117endforeach()
118
119###############################################################################
120### Extract rst from c++ headers ###
121
122set(EXTRACT_COMMAND "${CMAKE_SOURCE_DIR}/share/sphinx/ExtractRstFromSourceCPP.py")
123set(OCIO_HEADER_DIR "${CMAKE_SOURCE_DIR}/include/OpenColorIO")
124set(RST_DESTINATION "${CMAKE_BINARY_DIR}/docs/developers/api/")
125add_custom_target(rst_extraction
126    COMMAND ${CMAKE_COMMAND} -E make_directory ${RST_DESTINATION}
127    COMMAND ${PYTHON_EXECUTABLE} ${EXTRACT_COMMAND} ${OCIO_HEADER_DIR}/OpenColorIO.h ${RST_DESTINATION}/OpenColorIO.rst
128    COMMAND ${PYTHON_EXECUTABLE} ${EXTRACT_COMMAND} ${OCIO_HEADER_DIR}/OpenColorTransforms.h ${RST_DESTINATION}/OpenColorTransforms.rst
129    COMMAND ${PYTHON_EXECUTABLE} ${EXTRACT_COMMAND} ${OCIO_HEADER_DIR}/OpenColorTypes.h ${RST_DESTINATION}/OpenColorTypes.rst
130    COMMENT "Extracting .rst files from C++ headers"
131)
132
133###############################################################################
134### HTML doc target ###
135
136add_custom_target(docs ALL
137    COMMAND
138        ${PYT_PRE_CMD} "${SPHINX_EXECUTABLE}" -b html . "${CMAKE_CURRENT_BINARY_DIR}/build-html"
139    DEPENDS
140        OpenColorIO
141        PyOpenColorIO
142        ${CMAKE_BINARY_DIR}/docs/conf.py
143        rst_extraction
144        doc_copy
145        Sphinx
146    COMMENT "Building html docs"
147)
148
149###############################################################################
150### Installation ###
151
152install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build-html/
153        DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/OpenColorIO/html
154        PATTERN .* EXCLUDE
155)
156
157###############################################################################
158### PDF target ###
159
160find_package(LATEX)
161if(PDFLATEX_COMPILER)
162
163    add_custom_target(latex
164        COMMAND
165            ${PYT_PRE_CMD} "${SPHINX_EXECUTABLE}" -b latex . "${CMAKE_CURRENT_BINARY_DIR}/build-latex"
166        DEPENDS
167            OpenColorIO
168            PyOpenColorIO
169            ${CMAKE_BINARY_DIR}/docs/conf.py
170            rst_extraction
171            doc_copy
172            Sphinx
173        COMMENT "Building latex doc"
174    )
175
176    add_custom_target(pdf ALL
177        DEPENDS latex
178        COMMAND ${PDFLATEX_COMPILER} OpenColorIO.tex
179        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build-latex
180        COMMENT "Building pdf doc"
181    )
182
183    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/build-latex/OpenColorIO.pdf
184            DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/OpenColorIO/)
185
186endif()