aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2019-10-17 08:09:20 +0300
committerGitHub <noreply@github.com>2019-10-17 08:09:20 +0300
commit355aa42b48b187b5906ddeb506bae2279bc79ff9 (patch)
tree20d9682214dc5c2d8bf20e76698d035c3e24f08f
parent92873e9d27f11c333e5d0a40d58c2019d7770d0c (diff)
parent4f26548e3ab24c91e88bb0dd24415819c6add1b8 (diff)
downloadjansson-355aa42b48b187b5906ddeb506bae2279bc79ff9.zip
jansson-355aa42b48b187b5906ddeb506bae2279bc79ff9.tar.gz
jansson-355aa42b48b187b5906ddeb506bae2279bc79ff9.tar.bz2
Merge pull request #502 from AllenX2018/fix-issue453
fix issue #453:update FindSphinx.cmake to better align with find sphinx package.
-rw-r--r--cmake/FindSphinx.cmake24
1 files changed, 19 insertions, 5 deletions
diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake
index 55539d4..3bf0a5d 100644
--- a/cmake/FindSphinx.cmake
+++ b/cmake/FindSphinx.cmake
@@ -241,27 +241,42 @@ endif ()
# ----------------------------------------------------------------------------
# determine Sphinx version
+# some quick experiments by @ploxiln
+# - sphinx 1.7 and later have the version output format like "sphinx-build 1.7.2"
+# - sphinx 1.2 through 1.6 have the version output format like "Sphinx (sphinx-build) 1.2.2"
+# - sphinx 1.1 and before do not have a "--version" flag, but it causes the help output like "-h" does which includes version like "Sphinx v1.0.2"
if (Sphinx-build_EXECUTABLE)
# intentionally use invalid -h option here as the help that is shown then
# will include the Sphinx version information
if (Sphinx_PYTHON_EXECUTABLE)
execute_process (
- COMMAND "${Sphinx_PYTHON_EXECUTABLE}" ${Sphinx_PYTHON_OPTIONS} "${Sphinx-build_EXECUTABLE}" -h
+ COMMAND "${Sphinx_PYTHON_EXECUTABLE}" ${Sphinx_PYTHON_OPTIONS} "${Sphinx-build_EXECUTABLE}" --version
OUTPUT_VARIABLE _Sphinx_VERSION
ERROR_VARIABLE _Sphinx_VERSION
)
elseif (UNIX)
execute_process (
- COMMAND "${Sphinx-build_EXECUTABLE}" -h
+ COMMAND "${Sphinx-build_EXECUTABLE}" --version
OUTPUT_VARIABLE _Sphinx_VERSION
ERROR_VARIABLE _Sphinx_VERSION
)
endif ()
# The sphinx version can also contain a "b" instead of the last dot.
- # For example "Sphinx v1.2b1" so we cannot just split on "."
- if (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+(\\.|b)[0-9]+)")
+ # For example "Sphinx v1.2b1" or "Sphinx 1.7.0b2" so we cannot just split on "."
+ if (_Sphinx_VERSION MATCHES "sphinx-build ([0-9]+\\.[0-9]+(\\.|a?|b?)([0-9]*)(b?)([0-9]*))")
set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}")
+ set (_SPHINX_VERSION_FOUND)
+ elseif (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+(\\.|b?)([0-9]*)(b?)([0-9]*))")
+ set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}")
+ set (_SPHINX_VERSION_FOUND)
+ elseif (_Sphinx_VERSION MATCHES "Sphinx \\(sphinx-build\\) ([0-9]+\\.[0-9]+(\\.|a?|b?)([0-9]*)(b?)([0-9]*))")
+ set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}")
+ set (_SPHINX_VERSION_FOUND)
+ endif ()
+endif ()
+
+if(_SPHINX_VERSION_FOUND)
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})
@@ -270,7 +285,6 @@ if (Sphinx-build_EXECUTABLE)
if (Sphinx_VERSION_PATCH EQUAL 0)
string (REGEX REPLACE "\\.0$" "" Sphinx_VERSION_STRING "${Sphinx_VERSION_STRING}")
endif ()
- endif()
endif ()
# ----------------------------------------------------------------------------