From 2797ccb47075b337870ac3e902701e5171273dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Thu, 17 May 2018 18:30:18 +0200 Subject: [PATCH] Reworking of CMake scripts around documentation generation + Merging of ENABLE_SPHINX_DOC and ENABLE_DOC options. Only ENABLE_DOC remains. + Switching default value of ENABLE_DOC option to NO. + Adding tests for checking the presence of Python modules needed for documentation and wrappers generation. --- CMakeLists.txt | 13 +++++++--- cmake/Tools.cmake | 33 ++++++++++++++++++++++++++ coreapi/help/doc/sphinx/CMakeLists.txt | 2 +- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 cmake/Tools.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c0d68149e..ab7437ba7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ string(REGEX REPLACE "([a-zA-Z_]+)\\.po" "\\1" LINPHONE_ALL_LANGS_LIST "${LINPHO string(REPLACE ";" " " LINPHONE_ALL_LANGS "${LINPHONE_ALL_LANGS_LIST}") include(CMakeDependentOption) +include(cmake/Tools.cmake) option(ENABLE_SHARED "Build shared library." YES) option(ENABLE_STATIC "Build static library." YES) @@ -46,8 +47,7 @@ option(ENABLE_CXX_WRAPPER "Build the C++ wrapper for Liblinphone." YES) option(ENABLE_DAEMON "Enable the linphone daemon interface." YES) option(ENABLE_DATE "Use build date in internal version number." NO) option(ENABLE_DEBUG_LOGS "Turn on or off debug level logs." NO) -option(ENABLE_DOC "Enable documentation generation with Doxygen." YES) -option(ENABLE_SPHINX_DOC "Enable sphinx documentation generation." NO) +option(ENABLE_DOC "Enable API documentation generation." NO) option(ENABLE_JAVADOC "Add a target to generate documentation for Java API" NO) option(ENABLE_LDAP "Enable LDAP support." NO) option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO) @@ -173,8 +173,15 @@ if(ENABLE_LIME) endif() set(HAVE_LIME 1) endif() -if(ENABLE_CXX_WRAPPER OR ENABLE_CSHARP_WRAPPER OR ENABLE_JAVA_WRAPPER OR ENABLE_SPHINX_DOC) +if(ENABLE_CXX_WRAPPER OR ENABLE_CSHARP_WRAPPER OR ENABLE_JAVA_WRAPPER OR ENABLE_DOC) find_package(PythonInterp REQUIRED) + check_python_module(pystache) + check_python_module(six) + if(ENABLE_DOC) + check_python_module(sphinx) + check_python_module(javasphinx) + check_python_module(sphinx_csharp) + endif() endif() if(UNIX AND NOT APPLE) diff --git a/cmake/Tools.cmake b/cmake/Tools.cmake new file mode 100644 index 000000000..8c3d3d0c7 --- /dev/null +++ b/cmake/Tools.cmake @@ -0,0 +1,33 @@ +############################################################################ +# LinphoneUtils.cmake +# Copyright (C) 2018 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################################################ + +function(check_python_module module_name) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import ${module_name}" + RESULT_VARIABLE result + OUTPUT_QUIET + ERROR_QUIET) + if(result EQUAL 0) + message(STATUS "'${module_name}' python module found") + else() + message(FATAL_ERROR "'${module_name}' python module not found") + endif() +endfunction() diff --git a/coreapi/help/doc/sphinx/CMakeLists.txt b/coreapi/help/doc/sphinx/CMakeLists.txt index 55e54fc8f..5b1593126 100644 --- a/coreapi/help/doc/sphinx/CMakeLists.txt +++ b/coreapi/help/doc/sphinx/CMakeLists.txt @@ -20,7 +20,7 @@ # ############################################################################ -if (ENABLE_SPHINX_DOC) +if (ENABLE_DOC) set(doc_source_dir ${CMAKE_CURRENT_BINARY_DIR}/source) set(doc_output_dir ${CMAKE_CURRENT_BINARY_DIR}/build) set(reference_doc_source_dir ${doc_source_dir}/reference)