Sphinx and CMake, based on this example: http://ericscottbarr.com/blog/2012/03/sphinx-and-cmake-beautiful-documentation-for-c-projects/ The 'docs/CMakeLists.txt' file was deleted in this commit: 0abfb8f46f534b05413bb4d64b960d6fd0a9befb Thanks to Arnaud Gelas, he has passed some links: https://github.com/InsightSoftwareConsortium/ITKExamples/blob/master/CMake/FindSphinx.cmake https://github.com/InsightSoftwareConsortium/ITKExamples/blob/master/CMakeLists.txt#L120-L154 Change-Id: Ic65e7f8ec5280d1e71a897a144417a21761c5553
diff --git a/CMakeLists.txt b/CMakeLists.txt index b6c7359..e47ca52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -73,7 +73,11 @@ # # For versions without ABI changes, bump the smallest number in CERES_VERSION, # but leave the CERES_ABI_VERSION unchanged. -SET(CERES_VERSION 1.5.0) +SET(CERES_VERSION_MAJOR 1) +SET(CERES_VERSION_MINOR 5) +SET(CERES_VERSION_PATCH 0) +SET(CERES_VERSION + ${CERES_VERSION_MAJOR}.${CERES_VERSION_MINOR}.${CERES_VERSION_PATCH}) SET(CERES_ABI_VERSION 1.5.0) ENABLE_TESTING() @@ -646,13 +650,16 @@ ADD_SUBDIRECTORY(internal/ceres) OPTION(BUILD_DOCUMENTATION - "Build User's Guide (pdf)" + "Build User's Guide (html)" OFF) IF (${BUILD_DOCUMENTATION}) MESSAGE("-- Documentation building is enabled") - # Generate the User's Guide (pdf). + # Make CMake aware of the cmake folder, in order to find 'FindSphinx.cmake' + SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + + # Generate the User's Guide (html). # The corresponding target is UserGuide, but is included in ALL. ADD_SUBDIRECTORY(docs) ENDIF (${BUILD_DOCUMENTATION})
diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake new file mode 100644 index 0000000..cd55bbe --- /dev/null +++ b/cmake/FindSphinx.cmake
@@ -0,0 +1,35 @@ +# Find the Sphinx documentation generator +# +# This modules defines +# SPHINX_EXECUTABLE +# SPHINX_FOUND + +FIND_PROGRAM(SPHINX_EXECUTABLE + NAMES sphinx-build + PATHS + /usr/bin + /usr/local/bin + /opt/local/bin + DOC "Sphinx documentation generator") + +IF (NOT SPHINX_EXECUTABLE) + SET(_Python_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) + + FOREACH (_version ${_Python_VERSIONS}) + SET(_sphinx_NAMES sphinx-build-${_version}) + + FIND_PROGRAM(SPHINX_EXECUTABLE + NAMES ${_sphinx_NAMES} + PATHS + /usr/bin + /usr/local/bin + /opt/loca/bin + DOC "Sphinx documentation generator") + ENDFOREACH () +ENDIF () + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) + +MARK_AS_ADVANCED(SPHINX_EXECUTABLE)
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 0000000..6ebeaf1 --- /dev/null +++ b/docs/CMakeLists.txt
@@ -0,0 +1 @@ +ADD_SUBDIRECTORY(source)
diff --git a/docs/source/CMakeLists.txt b/docs/source/CMakeLists.txt new file mode 100644 index 0000000..f553a61 --- /dev/null +++ b/docs/source/CMakeLists.txt
@@ -0,0 +1,19 @@ +FIND_PACKAGE(Sphinx REQUIRED) + +# HTML output directory +SET(SPHINX_HTML_DIR "${CMAKE_BINARY_DIR}/docs/html") + +# Install documentation +INSTALL(DIRECTORY ${SPHINX_HTML_DIR} + DESTINATION ceres/doc + COMPONENT Doc + PATTERN "${SPHINX_HTML_DIR}/*") + +# Building using 'make_docs.py' python script +ADD_CUSTOM_TARGET(project_docs ALL + python + "${CMAKE_SOURCE_DIR}/scripts/make_docs.py" + "${CMAKE_SOURCE_DIR}" + "${CMAKE_BINARY_DIR}/docs" + "${SPHINX_EXECUTABLE}" + COMMENT "Building HTML documentation with Sphinx")
diff --git a/docs/source/conf.py b/docs/source/conf.py index 7fa6641..e114301 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py
@@ -48,7 +48,7 @@ # built documents. # # The short X.Y version. -version = '1.5.0' +version = '1.5' # The full version, including alpha/beta/rc tags. release = '1.5.0'
diff --git a/scripts/make_docs.py b/scripts/make_docs.py index 8f7e718..efbbf88 100644 --- a/scripts/make_docs.py +++ b/scripts/make_docs.py
@@ -36,17 +36,28 @@ import os import sys -if len(sys.argv) < 3: +# Number of arguments +N = len(sys.argv) + +if N < 3: print "make_docs.py src_root destination_root" sys.exit(1) -src_dir = sys.argv[1] + "/docs/source" +src_dir = sys.argv[1] + "/docs/source" build_root = sys.argv[2] -doctrees_dir = build_root + "/doctrees" -html_dir = build_root + "/html" +cache_dir = build_root + "/doctrees" +html_dir = build_root + "/html" + +# Called from Command Line +if N == 3: + sphinx_exe = "sphinx-build" + +# Called from CMake (using the SPHINX_EXECUTABLE found) +elif N == 4: + sphinx_exe = sys.argv[3] # Run Sphinx to build the documentation. -os.system("sphinx-build -b html -d %s %s %s" %(doctrees_dir, src_dir, html_dir)) +os.system("%s -b html -d %s %s %s" %(sphinx_exe, cache_dir, src_dir, html_dir)) input_pattern = """config=TeX-AMS-MML_HTMLorMML"></script>""" output_pattern = """config=TeX-AMS_HTML">
diff --git a/scripts/make_release b/scripts/make_release index 36643e9..d3ca820 100755 --- a/scripts/make_release +++ b/scripts/make_release
@@ -40,9 +40,9 @@ TMP="/tmp/ceres-solver-$1" DOCS_TMP="/tmp/ceres-solver-docs-$1" -VERSION=$(grep 'SET(CERES_VERSION' CMakeLists.txt | \ - sed -e 's/SET(CERES_VERSION //' | \ - sed -e 's/)//') +VERSION=$(grep 'SET(CERES_VERSION_' CMakeLists.txt | \ + sed -e 's/\(.*\) \(.*\))/\2/' | \ + tr '\n' '.' | sed -e 's/.$//') ABI_VERSION=$(grep 'SET(CERES_ABI_VERSION' CMakeLists.txt | \ sed -e 's/SET(CERES_ABI_VERSION //' | \ sed -e 's/)//') @@ -89,9 +89,8 @@ exit 1 fi -# Clone the repository and clean out the git extras. -git clone . $TMP -rm -rf "$TMP/.git" +# Export repository. +git checkout-index -f -a --prefix=$TMP/ # Build the VERSION file. VERSIONFILE=$TMP/VERSION