From 56fad3ffbb03b2e06fba212342ed0f22c0673687 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 22 Jan 2016 19:15:51 +0300 Subject: [PATCH] Merge relevant changes from V8_0_0_BR branch --- CMakeModules/FindSphinx.cmake | 11 +++ CMakeModules/SalomeDocumentationMacros.cmake | 78 +++++++++++--------- CMakeModules/SalomeMacros.cmake | 32 ++++---- dev/cmake/CMakeLists.txt | 4 +- dev/cmake/source/{conf.py => conf.py.in} | 2 +- dev/git/CMakeLists.txt | 4 +- dev/git/{conf.py => conf.py.in} | 2 +- 7 files changed, 79 insertions(+), 54 deletions(-) rename dev/cmake/source/{conf.py => conf.py.in} (99%) rename dev/git/{conf.py => conf.py.in} (99%) diff --git a/CMakeModules/FindSphinx.cmake b/CMakeModules/FindSphinx.cmake index 1c9c6a8..648d170 100644 --- a/CMakeModules/FindSphinx.cmake +++ b/CMakeModules/FindSphinx.cmake @@ -38,7 +38,18 @@ IF(WIN32) ELSE() SET(SPHINX_PYTHONPATH "${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages") ENDIF() + # Handle the standard arguments of the find_package() command: INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx REQUIRED_VARS SPHINX_EXECUTABLE SPHINX_APIDOC_EXECUTABLE) +IF(SPHINX_EXECUTABLE) + EXECUTE_PROCESS(COMMAND ${SPHINX_EXECUTABLE} "--version" OUTPUT_VARIABLE SPHINX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + STRING(REGEX REPLACE ".* ([0-9.]+)$" "\\1" SPHINX_VERSION "${SPHINX_VERSION}" ) + MESSAGE(STATUS "Sphinx version is ${SPHINX_VERSION}") + IF(SPHINX_VERSION VERSION_LESS "1.3") + SET(SPHINX_THEME "basic") + ELSE() + SET(SPHINX_THEME "classic") + ENDIF() +ENDIF(SPHINX_EXECUTABLE) diff --git a/CMakeModules/SalomeDocumentationMacros.cmake b/CMakeModules/SalomeDocumentationMacros.cmake index 70ee6bc..5bde525 100644 --- a/CMakeModules/SalomeDocumentationMacros.cmake +++ b/CMakeModules/SalomeDocumentationMacros.cmake @@ -22,7 +22,7 @@ #---------------------------------------------------------------------------- # SALOME_ADD_SPHINX_DOC is a macro useful for generating sphinx documentation # -# USAGE: SALOME_ADD_SPHINX_DOC(sphinx_type [path1 path2 ... ]) +# USAGE: SALOME_ADD_SPHINX_DOC(sphinx_type sphinx_name src_dir cfg_dir) # # ARGUMENTS: # @@ -50,7 +50,10 @@ # # sphinx_name: IN - documentation target name # -# path : IN - optional arguments, list of the paths whese contains the sphinx configuration files. +# src_dir : IN - path to directory that contains the sphinx source files +# +# cfg_dir : IN - path to directory that contains sphinx configuration file (if not specified, +# it is considered equal to src_dir) # # ADDITIONAL SETTINGS: # @@ -61,46 +64,49 @@ # BUILDDIR - local sphinx build directory ("_build" by default) #---------------------------------------------------------------------------- -MACRO(SALOME_ADD_SPHINX_DOC sphinx_type sphinx_name) +MACRO(SALOME_ADD_SPHINX_DOC sphinx_type sphinx_name src_dir cfg_dir) -# Get type and additional settings - SET(SPHINX_TYPE ${sphinx_type}) - IF(${SPHINX_TYPE} STREQUAL "") - SET(SPHINX_TYPE html) - ENDIF(${SPHINX_TYPE} STREQUAL "") + # Get type and additional settings + SET(SPHINX_TYPE ${sphinx_type}) + IF(${SPHINX_TYPE} STREQUAL "") + SET(SPHINX_TYPE html) + ENDIF(${SPHINX_TYPE} STREQUAL "") - IF("${PAPER}" STREQUAL "") - SET(PAPER a4) - ENDIF() + IF("${PAPER}" STREQUAL "") + SET(PAPER a4) + ENDIF() - IF("${BUILDDIR}" STREQUAL "") - SET(BUILDDIR _build) - ENDIF() + IF("${BUILDDIR}" STREQUAL "") + SET(BUILDDIR _build) + ENDIF() + + SET(SPHINX_CFG ${cfg_dir}) + IF("${SPHINX_CFG}" STREQUAL "") + SET(SPHINX_CFG ${src_dir}) + ENDIF() - # Initialize internal variables - SET(PAPEROPT_a4 -D latex_paper_size=a4) - SET(PAPEROPT_letter -D latex_paper_size=letter) - SET(ALLSPHINXOPTS -d ${BUILDDIR}/doctrees ${PAPEROPT_${PAPER}} ${SPHINXOPTS}) - SET(I18NSPHINXOPTS ${PAPEROPT_${PAPER}} ${SPHINXOPTS}) + # Initialize internal variables + SET(PAPEROPT_a4 -D latex_paper_size=a4) + SET(PAPEROPT_letter -D latex_paper_size=letter) + SET(ALLSPHINXOPTS -d ${BUILDDIR}/doctrees ${PAPEROPT_${PAPER}} ${SPHINXOPTS}) + SET(I18NSPHINXOPTS ${PAPEROPT_${PAPER}} ${SPHINXOPTS}) - FOREACH(value ${ARGN}) - SET(ALLSPHINXOPTS ${ALLSPHINXOPTS} ${value}) - SET(I18NSPHINXOPTS ${I18NSPHINXOPTS} ${value}) - ENDFOREACH(value ${ARGN}) + SET(ALLSPHINXOPTS ${ALLSPHINXOPTS} ${src_dir}) + SET(I18NSPHINXOPTS ${I18NSPHINXOPTS} ${src_dir}) - # Set internal out directory - SET(_OUT_DIR ${sphinx_type}) - IF(${sphinx_type} STREQUAL "gettext") - SET(_OUT_DIR gettext) - SET(ALLSPHINXOPTS ${I18NSPHINXOPTS}) - ENDIF(${sphinx_type} STREQUAL "gettext") + # Set internal out directory + SET(_OUT_DIR ${SPHINX_TYPE}) + IF(${SPHINX_TYPE} STREQUAL "gettext") + SET(_OUT_DIR gettext) + SET(ALLSPHINXOPTS ${I18NSPHINXOPTS}) + ENDIF(${SPHINX_TYPE} STREQUAL "gettext") - # Build sphinx command - SET(_CMD_OPTIONS -b ${sphinx_type} ${ALLSPHINXOPTS} ${BUILDDIR}/${_OUT_DIR}) + # Build sphinx command + SET(_CMD_OPTIONS -b ${SPHINX_TYPE} -c ${SPHINX_CFG} ${ALLSPHINXOPTS} ${BUILDDIR}/${_OUT_DIR}) - # This macro mainly prepares the environment in which sphinx should run: - # this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ... - SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd env_script "${SPHINX_EXECUTABLE}" "${_CMD_OPTIONS}") - ADD_CUSTOM_TARGET(${sphinx_name} ALL ${_cmd}) + # This macro mainly prepares the environment in which sphinx should run: + # this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ... + SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd env_script "${SPHINX_EXECUTABLE}" "${_CMD_OPTIONS}") + ADD_CUSTOM_TARGET(${sphinx_name} ALL ${_cmd}) -ENDMACRO(SALOME_ADD_SPHINX_DOC sphinx_type) \ No newline at end of file +ENDMACRO(SALOME_ADD_SPHINX_DOC) diff --git a/CMakeModules/SalomeMacros.cmake b/CMakeModules/SalomeMacros.cmake index 25a22bd..34f8578 100644 --- a/CMakeModules/SalomeMacros.cmake +++ b/CMakeModules/SalomeMacros.cmake @@ -473,6 +473,7 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ## ## 0. Initialization ## + PARSE_ARGUMENTS(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS "ENVVAR" "" ${ARGN}) # Package name, upper case STRING(TOUPPER ${pkg} pkg_UC) @@ -480,22 +481,25 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ## ## 1. Load environment or any previously detected root dir for the package ## - IF(DEFINED ENV{${pkg_UC}_ROOT_DIR}) - FILE(TO_CMAKE_PATH "$ENV{${pkg_UC}_ROOT_DIR}" _${pkg_UC}_ROOT_DIR_ENV) + SET(_envvar ${pkg_UC}_ROOT_DIR) + IF(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR) + SET(_envvar "${SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR}") + ENDIF() + IF(DEFINED ENV{${_envvar}}) + FILE(TO_CMAKE_PATH "$ENV{${_envvar}}" _${pkg_UC}_ROOT_DIR_ENV) SET(_dflt_value "${_${pkg_UC}_ROOT_DIR_ENV}") ELSE() # will be blank if no package was previously loaded: SET(_dflt_value "${${pkg_UC}_ROOT_DIR_EXP}") ENDIF() - # Detect if the variable has been set on the command line or elsewhere: - IF(DEFINED ${pkg_UC}_ROOT_DIR) + IF(DEFINED ${_envvar}) SET(_var_already_there TRUE) ELSE() SET(_var_already_there FALSE) ENDIF() # Make cache entry - SET(${pkg_UC}_ROOT_DIR "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory") + SET(${_envvar} "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory") ## ## 2. Find package - try CONFIG mode first (i.e. looking for XYZ-config.cmake) @@ -503,8 +507,8 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) # Override the variable - don't append to it, as it would give precedence # to what was stored there before! - IF(DEFINED ${pkg_UC}_ROOT_DIR) - SET(CMAKE_PREFIX_PATH "${${pkg_UC}_ROOT_DIR}") + IF(DEFINED ${_envvar}) + SET(CMAKE_PREFIX_PATH "${${_envvar}}") ENDIF() # Try find_package in config mode. This has the priority, but is @@ -531,11 +535,11 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) IF(NOT Salome${pkg}_FIND_QUIETLY) IF(Salome${pkg}_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? " - "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR} " + "It currently contains ${_envvar}=${${_envvar}} " "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.") ELSE() MESSAGE(WARNING "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? " - "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR} " + "It currently contains ${_envvar}=${${_envvar}} " "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.") ENDIF() ENDIF() @@ -568,19 +572,19 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ## ## 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR) ## - IF(DEFINED ENV{${pkg_UC}_ROOT_DIR}) + IF(DEFINED ENV{${_envvar}}) SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_${pkg_UC}_ROOT_DIR_ENV}") IF(NOT _res) MESSAGE(WARNING "${pkg} was found, but not at the path given by the " - "environment ${pkg_UC}_ROOT_DIR! Is the variable correctly set? " + "environment ${_envvar}! Is the variable correctly set? " "The two paths are: ${_tmp_ROOT_DIR} and: ${_${pkg_UC}_ROOT_DIR_ENV}") ELSE() - MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${pkg_UC}_ROOT_DIR variable, all good!") + MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${_envvar} variable, all good!") ENDIF() ELSE() IF(NOT _var_already_there) - MESSAGE(STATUS "Variable ${pkg_UC}_ROOT_DIR was not explicitly defined. " + MESSAGE(STATUS "Variable ${_envvar} was not explicitly defined. " "An installation was found anyway: ${_tmp_ROOT_DIR}") ENDIF() ENDIF() @@ -602,7 +606,7 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ## ## 6. Save the detected installation ## - SET(${pkg_UC}_ROOT_DIR "${_tmp_ROOT_DIR}") + SET(${_envvar} "${_tmp_ROOT_DIR}") ELSE() MESSAGE(STATUS "${pkg} was not found.") diff --git a/dev/cmake/CMakeLists.txt b/dev/cmake/CMakeLists.txt index 8dbde37..bd8f474 100644 --- a/dev/cmake/CMakeLists.txt +++ b/dev/cmake/CMakeLists.txt @@ -21,9 +21,11 @@ # ================== INCLUDE(SalomeDocumentationMacros) +SALOME_CONFIGURE_FILE(source/conf.py.in conf.py) + # Add sphinx documentation target # ============================ -SALOME_ADD_SPHINX_DOC( html cmake_doc ${CMAKE_CURRENT_SOURCE_DIR}/source) +SALOME_ADD_SPHINX_DOC(html cmake_doc ${CMAKE_CURRENT_SOURCE_DIR}/source ${CMAKE_CURRENT_BINARY_DIR}) # Install rules # ========== diff --git a/dev/cmake/source/conf.py b/dev/cmake/source/conf.py.in similarity index 99% rename from dev/cmake/source/conf.py rename to dev/cmake/source/conf.py.in index 2cc94de..383d92a 100644 --- a/dev/cmake/source/conf.py +++ b/dev/cmake/source/conf.py.in @@ -91,7 +91,7 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = '@SPHINX_THEME@' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/dev/git/CMakeLists.txt b/dev/git/CMakeLists.txt index 611fa0c..8bb7daa 100644 --- a/dev/git/CMakeLists.txt +++ b/dev/git/CMakeLists.txt @@ -21,9 +21,11 @@ # ================== INCLUDE(SalomeDocumentationMacros) +SALOME_CONFIGURE_FILE(conf.py.in conf.py) + # Add sphinx documentation target # ============================ -SALOME_ADD_SPHINX_DOC( html git_doc ${CMAKE_CURRENT_SOURCE_DIR}) +SALOME_ADD_SPHINX_DOC( html git_doc ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) # Install rules # ========== diff --git a/dev/git/conf.py b/dev/git/conf.py.in similarity index 99% rename from dev/git/conf.py rename to dev/git/conf.py.in index 75375e5..a3c1ca6 100644 --- a/dev/git/conf.py +++ b/dev/git/conf.py.in @@ -91,7 +91,7 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = '@SPHINX_THEME@' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the -- 2.39.2