123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- set (_Sphinx_REQUIRED_VARS)
- if (NOT Sphinx_DIR)
- if (NOT $ENV{Sphinx_DIR} STREQUAL "")
- set (Sphinx_DIR "$ENV{Sphinx_DIR}" CACHE PATH "Installation prefix of Sphinx (docutils)." FORCE)
- else ()
- set (Sphinx_DIR "$ENV{SPHINX_DIR}" CACHE PATH "Installation prefix of Sphinx (docutils)." FORCE)
- endif ()
- endif ()
- if (NOT Sphinx_FIND_COMPONENTS)
- set (Sphinx_FIND_COMPONENTS "build")
- elseif (NOT Sphinx_FIND_COMPONENTS MATCHES "^(build|apidoc)$")
- message (FATAL_ERROR "Invalid Sphinx component in: ${Sphinx_FIND_COMPONENTS}")
- endif ()
- foreach (_Sphinx_TOOL IN LISTS Sphinx_FIND_COMPONENTS)
- if (Sphinx_DIR)
- find_program (
- Sphinx-${_Sphinx_TOOL}_EXECUTABLE
- NAMES sphinx-${_Sphinx_TOOL} sphinx-${_Sphinx_TOOL}.py
- HINTS "${Sphinx_DIR}"
- PATH_SUFFIXES bin
- DOC "The sphinx-${_Sphinx_TOOL} Python script."
- NO_DEFAULT_PATH
- )
- else ()
- find_program (
- Sphinx-${_Sphinx_TOOL}_EXECUTABLE
- NAMES sphinx-${_Sphinx_TOOL} sphinx-${_Sphinx_TOOL}.py
- DOC "The sphinx-${_Sphinx_TOOL} Python script."
- )
- endif ()
- mark_as_advanced (Sphinx-${_Sphinx_TOOL}_EXECUTABLE)
- list (APPEND _Sphinx_REQUIRED_VARS Sphinx-${_Sphinx_TOOL}_EXECUTABLE)
- endforeach ()
- if (Sphinx-build_EXECUTABLE)
-
- find_package (PythonInterp QUIET)
- set (Sphinx_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")
- set (Sphinx_PYTHON_OPTIONS)
- file (STRINGS "${Sphinx-build_EXECUTABLE}" FIRST_LINE LIMIT_COUNT 1)
- if (FIRST_LINE MATCHES "^#!(.*/python.*)")
- string (REGEX REPLACE "^ +| +$" "" Sphinx_PYTHON_EXECUTABLE "${CMAKE_MATCH_1}")
- if (Sphinx_PYTHON_EXECUTABLE MATCHES "([^ ]+) (.*)")
- set (Sphinx_PYTHON_EXECUTABLE "${CMAKE_MATCH_1}")
- string (REGEX REPLACE " +" ";" Sphinx_PYTHON_OPTIONS "${CMAKE_MATCH_2}")
- endif ()
- endif ()
-
-
- string (REGEX REPLACE "([.+*?^$])" "\\\\\\1" _Sphinx_PYTHON_EXECUTABLE_RE "${PYTHON_EXECUTABLE}")
- list (FIND Sphinx_PYTHON_OPTIONS -E IDX)
- if (IDX EQUAL -1 AND NOT Sphinx_PYTHON_EXECUTABLE MATCHES "^${_Sphinx_PYTHON_EXECUTABLE_RE}$")
- list (INSERT Sphinx_PYTHON_OPTIONS 0 -E)
- endif ()
- unset (_Sphinx_PYTHON_EXECUTABLE_RE)
- endif ()
- if (Sphinx-build_EXECUTABLE)
-
-
- if (Sphinx_PYTHON_EXECUTABLE)
- execute_process (
- COMMAND "${Sphinx_PYTHON_EXECUTABLE}" ${Sphinx_PYTHON_OPTIONS} "${Sphinx-build_EXECUTABLE}" -h
- OUTPUT_VARIABLE _Sphinx_VERSION
- ERROR_VARIABLE _Sphinx_VERSION
- )
- elseif (UNIX)
- execute_process (
- COMMAND "${Sphinx-build_EXECUTABLE}" -h
- OUTPUT_VARIABLE _Sphinx_VERSION
- ERROR_VARIABLE _Sphinx_VERSION
- )
- endif ()
-
-
- if (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+(\\.|b)[0-9]+)")
- set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}")
- string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.|b)[0-9]+" "\\1" Sphinx_VERSION_MAJOR ${Sphinx_VERSION_STRING})
- string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.|b)[0-9]+" "\\1" Sphinx_VERSION_MINOR ${Sphinx_VERSION_STRING})
- string(REGEX REPLACE "[0-9]+\\.[0-9]+(\\.|b)([0-9]+)" "\\1" Sphinx_VERSION_PATCH ${Sphinx_VERSION_STRING})
-
- if (Sphinx_VERSION_PATCH EQUAL 0)
- string (REGEX REPLACE "\\.0$" "" Sphinx_VERSION_STRING "${Sphinx_VERSION_STRING}")
- endif ()
- endif()
- endif ()
- set (SPHINX_EXECUTABLE "${Sphinx-build_EXECUTABLE}")
- include (FindPackageHandleStandardArgs)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS (
- Sphinx
- REQUIRED_VARS
- ${_Sphinx_REQUIRED_VARS}
- Sphinx_VERSION_STRING
- )
- if (NOT Sphinx_DIR AND Sphinx-build_EXECUTABLE)
- get_filename_component (Sphinx_DIR "${Sphinx-build_EXECUTABLE}" PATH)
- string (REGEX REPLACE "/bin/?" "" Sphinx_DIR "${Sphinx_DIR}")
- set (Sphinx_DIR "${Sphinx_DIR}" CACHE PATH "Installation directory of Sphinx tools." FORCE)
- endif ()
- unset (_Sphinx_VERSION)
- unset (_Sphinx_REQUIRED_VARS)
|