]> SALOME platform Git repositories - tools/configuration.git/commitdiff
Salome HOME
Improve documentation generation.
authorrnv <rnv@opencascade.com>
Mon, 26 Aug 2019 16:15:50 +0000 (19:15 +0300)
committerrnv <rnv@opencascade.com>
Thu, 29 Aug 2019 14:04:40 +0000 (17:04 +0300)
cmake/FindPyQt5.cmake
cmake/FindSalomeLibXml2.cmake
cmake/FindSalomeOpenCASCADE.cmake
cmake/SalomeMacros.cmake
cmake/UseSphinx.cmake

index 4b1ad34f6568a206019dd0225286b2cdc7ac3394..f893e0fce24ccfa506dc2f6ca26eee8d40430f76 100644 (file)
@@ -65,7 +65,7 @@ ENDIF()
 MARK_AS_ADVANCED(PYQT_SIP_MAIN_FILE)
 
 # Get PyQt compilation flags:
-SET(PYQT_PYTHONPATH "${_tmp_ROOT_DIR}/PyQt5;${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/PyQt5")
+SET(PYQT_PYTHONPATH "${_tmp_ROOT_DIR};${_tmp_ROOT_DIR}/PyQt5;${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/PyQt5")
 SET(PYQT_SIPFLAGS)
 
 EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; 
index e4d58b2f5ce851dd7ef189d4f74deaed7014d509..1303c06a2901ffb16926b1997db369361a6633c4 100644 (file)
@@ -31,4 +31,8 @@ ENDIF()
 IF(LIBXML2_FOUND) 
   SALOME_ACCUMULATE_HEADERS(LIBXML2_INCLUDE_DIR)
   SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${LIBXML2_LIBRARIES})
+  IF(WIN32 AND LIBXML2_XMLLINT_EXECUTABLE)
+    GET_FILENAME_COMPONENT(LIBXML2_BIN_DIR ${LIBXML2_XMLLINT_EXECUTABLE} DIRECTORY)
+    SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${LIBXML2_BIN_DIR})
+  ENDIF()
 ENDIF()
index 257b896e10e06da611d0f9759f04735315ce535b..8dea8dfa929dc29444e27c1c41246cd46df1cc76 100644 (file)
@@ -43,6 +43,16 @@ IF(OpenCASCADE_FOUND)
 
   SALOME_ACCUMULATE_HEADERS(OpenCASCADE_INCLUDE_DIR)
   SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${OpenCASCADE_LIBRARY_DIR})
+  IF(WIN32)
+    # RNV: Fix bug with OCCT CMake build procedure:
+    #      In Debug ${OpenCASCADE_BINARY_DIR} and ${OpenCASCADE_LIBRARY_DIR} are stored in the
+    #      config file w/o "d" suffix. To be checked with latest version of OCCT.
+    SET(SUFF "")
+    IF(${OpenCASCADE_BUILD_TYPE} STREQUAL "Debug")
+      SET(SUFF "d")
+    ENDIF()
+    SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${OpenCASCADE_BINARY_DIR}${SUFF})
+  ENDIF()
 
 ELSE()
   # TODO: Detect OpenCASCADE if it is distributed without CMake configuration.
index 22e9c61828cff3d43ed8e409b9993d7e275cc033..79c77e06442e7aa080990769324f34d1a7be1921 100644 (file)
@@ -793,14 +793,39 @@ ENDMACRO(SALOME_ACCUMULATE_ENVIRONMENT)
 # Macro generates environement script using previously created variables
 # _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable and
 # _${PROJECT_NAME}_EXTRA_ENV (see marco SALOME_ACCUMULATE_ENVIRONMENT);
-# and puts generated command in proper environment into <output> argument.
-# 
+# and puts generated command in proper environment into <output> argument. To ignore
+# _${PROJECT_NAME}_EXTRA_ENV_<var> and _${PROJECT_NAME}_EXTRA_ENV variables set 
+# environment variable 'SALOME_HAS_GLOBAL_ENV=1'
+#
+# NAMED ARGUMENTS:
+#  CONTEXT: is used under Windows platform only to generate command file. See explanations 
+#           below.
+#  CONTEXT_NAME: is used under Windows platform only to generate command file. See 
+#                explanations below. 
+#  ADDITIONAL_VARIABLES: list of the additional variables to write into environment script.
+#                        Each item of this list should be in the 'Variable=Value' format.
+#
+#
 # Notes:
 # - If <script> is specified as relative path, it is computed from the current build
 #   directory.
+# - If CONTEXT variables is passed into this macro, then on 
+#   Windows platform command file looks like:
+#   =================================================
+#   IF SET_${CONTEXT}_VARS == 1 GOTO ${CONTEXT_NAME}
+#    @SET VAR1=VAR1_VALUE;%VAR1%
+#    .........
+#    .........
+#    .........
+#    @SET VARN=VARN_VALUE;%VARN%
+#    @SET SET_${CONTEXT}_VARS = 1
+#   :${CONTEXT_NAME}
+#   ================================================= 
+#   By default CONTEXT_NAME is equal to 'END'
 #
 MACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT output script cmd opts)
-  PARSE_ARGUMENTS(SALOME_GENERATE_ENVIRONMENT_SCRIPT "CONTEXT" "" ${ARGN})
+  PARSE_ARGUMENTS(SALOME_GENERATE_ENVIRONMENT_SCRIPT "CONTEXT;CONTEXT_NAME;ADDITIONAL_VARIABLES" "" ${ARGN})
+  
   IF(IS_ABSOLUTE ${script})
     SET(_script ${script})
   ELSE()
@@ -814,40 +839,51 @@ MACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT output script cmd opts)
     SET(_ext "sh")
     SET(_call_cmd ".")
   ENDIF()
+
+  SET(_ctx "END")
+  IF(SALOME_GENERATE_ENVIRONMENT_SCRIPT_CONTEXT_NAME)
+    SET(_ctx "${SALOME_GENERATE_ENVIRONMENT_SCRIPT_CONTEXT_NAME}")
+  ENDIF()
   
-  SET(_env)
+  SET(_env "")
   IF(WIN32 AND SALOME_GENERATE_ENVIRONMENT_SCRIPT_CONTEXT)
-    SET(_env "IF ${_env}\"%SET_${SALOME_GENERATE_ENVIRONMENT_SCRIPT_CONTEXT}_VARS%\"==\"1\" GOTO END\n")
+    SET(_env "IF ${_env}\"%SET_${SALOME_GENERATE_ENVIRONMENT_SCRIPT_CONTEXT}_VARS%\"==\"1\" GOTO ${_ctx}\n")
   ENDIF()
-  FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
-    FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
-      IF(WIN32)
-        IF(${_item} STREQUAL "LD_LIBRARY_PATH")
-          SET(_item PATH)
-        ENDIF()
-        STRING(REPLACE "/" "\\" _env "${_env}@SET ${_item}=${_val};%${_item}%\n")        
-      ELSEIF(APPLE)
-        IF(${_item} STREQUAL "LD_LIBRARY_PATH")
-          SET(_env "${_env} export DYLD_LIBRARY_PATH=${_val}:\${DYLD_LIBRARY_PATH}\n")
-        ELSE()
-          SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
-        ENDIF()
-      ELSE()
-        SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
+  IF (NOT "$ENV{SALOME_HAS_GLOBAL_ENV}" STREQUAL "1")
+    FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
+      FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
+        SALOME_DO_VAR_SUBSTITUTION(_env ${_item} ${_val})
+      ENDFOREACH()
+    ENDFOREACH()
+  ENDIF()
+
+  # Additional variables
+  IF(SALOME_GENERATE_ENVIRONMENT_SCRIPT_ADDITIONAL_VARIABLES)
+    FOREACH(_item ${SALOME_GENERATE_ENVIRONMENT_SCRIPT_ADDITIONAL_VARIABLES})
+      STRING(REGEX MATCHALL "([^=]+|[^=]+$)" a_list "${_item}")
+      LIST(LENGTH a_list a_list_len)
+      IF(NOT ${a_list_len} EQUAL 2) 
+        MESSAGE(FATAL_ERROR  "Each item of ${ADDITIONAL_VARIABLES} list should be in 'Variable=Value' format")
       ENDIF()
+      LIST(GET a_list 0 _item)
+      LIST(GET a_list 1 _val)
+      SALOME_DO_VAR_SUBSTITUTION(_env ${_item} ${_val})
     ENDFOREACH()
-  ENDFOREACH()
+  ENDIF()
+
   IF(WIN32 AND SALOME_GENERATE_ENVIRONMENT_SCRIPT_CONTEXT)
-    SET(_env "${_env}@SET SET_${SALOME_GENERATE_ENVIRONMENT_SCRIPT_CONTEXT}_VARS=1\n")
-    SET(_env "${_env}:END\n" )
+     SET(_env "${_env}@SET SET_${SALOME_GENERATE_ENVIRONMENT_SCRIPT_CONTEXT}_VARS=1\n")
+     SET(_env "${_env}:${_ctx}\n" )
   ENDIF()
 
-  
-  SET(_script ${_script}.${_ext})
-  FILE(WRITE ${_script} "${_env}")
-  
-  SET(${output} ${_call_cmd} ${_script} && ${cmd} ${opts})
-  
+  IF(NOT "${_env}" STREQUAL "")
+    SET(_script ${_script}.${_ext})
+    FILE(WRITE ${_script} "${_env}")
+    SET(${output} ${_call_cmd} ${_script} && ${cmd} ${opts})
+  ELSE()
+    SET(${output} ${cmd} ${opts})
+  ENDIF()
+    
 ENDMACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT)
 
 #########################################################################
@@ -1051,3 +1087,43 @@ MACRO(SWIG_CHECK_GENERATION swig_module)
   ENDIF()
 ENDMACRO(SWIG_CHECK_GENERATION)
 
+#########################################################################
+# SALOME_DO_VAR_SUBSTITUTION()
+#
+# USAGE: SALOME_DO_VAR_SUBSTITUTION(env variable value)
+#
+# ARGUMENTS:
+#   env      [out]: output script.
+#   variable  [in]: varable name
+#   value     [in]: variable value
+#
+# This macro concatenate variable value into script, like this:
+# on Linux:
+# export variable=value:${varuable}
+#
+# or on Windows:
+# SET variable=value;${varuable}
+#
+# Platform dependat variables PATH (Windows), 
+# DYLD_LIBRARY_PATH (Apple), LD_LIBRARY_PATH (Linux), should be
+# passed in Linux naming style, i.e. LD_LIBRARY_PATH. Macro 
+# converts this variable into platform scpecific variable.
+#
+MACRO(SALOME_DO_VAR_SUBSTITUTION env variable value)
+  SET(_item ${variable})
+  SET(_val ${value})
+  IF(WIN32)
+    IF(${_item} STREQUAL "LD_LIBRARY_PATH")
+      SET(_item PATH)
+    ENDIF()
+      STRING(REPLACE "/" "\\" ${env} "${${env}}@SET ${_item}=${_val};%${_item}%\n")        
+    ELSEIF(APPLE)
+      IF(${_item} STREQUAL "LD_LIBRARY_PATH")
+        SET(${env} "${${env}} export DYLD_LIBRARY_PATH=${_val}:\${DYLD_LIBRARY_PATH}\n")
+      ELSE()
+        SET(${env} "${${env}} export ${_item}=${_val}:\${${_item}}\n")
+      ENDIF()
+    ELSE()
+       SET(${env} "${${env}} export ${_item}=${_val}:\${${_item}}\n")
+  ENDIF()
+ENDMACRO(SALOME_DO_VAR_SUBSTITUTION)
index 7e952f2c1ed58a2f4f27e2d5f66af3f80dc8a6d9..2b46a15aa58e6e12b82df2d6b47208819998b77b 100644 (file)
@@ -48,13 +48,15 @@ endfunction()
 # TARGET_NAME : IN : target name for the documentation
 # MODULE : IN : SALOME module name
 # LANGUAGES : IN : list of the languages
+# ADDITIONAL_ENVIRONMENT: IN : list of additional enviromnent variable used 
+# for generation of the documentation
 #----------------------------------------------------------------------------
 MACRO(ADD_MULTI_LANG_DOCUMENTATION)
   # Common options
   SET(PAPEROPT_a4 "-D latex_paper_size=a4")
 
   # Parse input argument
-  PARSE_ARGUMENTS(MULTI_LANG "TARGET_NAME;MODULE;LANGUAGES" "" ${ARGN})
+  PARSE_ARGUMENTS(MULTI_LANG "TARGET_NAME;MODULE;LANGUAGES;ADDITIONAL_ENVIRONMENT" "" ${ARGN})
 
   # Content of the executable file to generate documentation
   SET(CMDS)
@@ -90,44 +92,17 @@ MACRO(ADD_MULTI_LANG_DOCUMENTATION)
   ENDFOREACH()
 
   # 6. Create command file
+  SET(_script_wo "build_doc")
   IF(WIN32)
     SET(_ext "bat")
-    SET(_call_cmd "call")
   ELSE()
     SET(_ext "sh")
-    SET(_call_cmd ".")
-  ENDIF()
-  
-  SET(_env)
-  IF(WIN32)
-    SET(_env "IF ${_env}\"%SET_${MULTI_LANG_TARGET_NAME}_VARS%\"==\"1\" GOTO DO_GENERATION\n")
-  ENDIF()  
-  FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
-    FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
-      IF(WIN32)
-        IF(${_item} STREQUAL "LD_LIBRARY_PATH")
-          SET(_item PATH)
-        ENDIF()
-        STRING(REPLACE "/" "\\" _env "${_env} @SET ${_item}=${_val}\;%${_item}%\n")        
-      ELSEIF(APPLE)
-        IF(${_item} STREQUAL "LD_LIBRARY_PATH")
-          SET(_env "${_env} export DYLD_LIBRARY_PATH=${_val}:\${DYLD_LIBRARY_PATH}\n")
-        ELSE()
-          SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
-        ENDIF()
-      ELSE()
-        SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
-      ENDIF()
-    ENDFOREACH()
-  ENDFOREACH()
-  IF(WIN32)
-    SET(_env "${_env}@SET SET_${MULTI_LANG_TARGET_NAME}_VARS=1\n")
-    SET(_env "${_env}:DO_GENERATION\n" )
   ENDIF()
+  SET(_script "${_script_wo}.${_ext}")
+
+  SALOME_GENERATE_ENVIRONMENT_SCRIPT(_not_used_output ${_script_wo} "" "" CONTEXT "${MULTI_LANG_TARGET_NAME}" CONTEXT_NAME "DO_GENERATION" ADDITIONAL_VARIABLES ${MULTI_LANG_ADDITIONAL_ENVIRONMENT})
 
-  
-  SET(_script ${CMAKE_CURRENT_BINARY_DIR}/build_doc.${_ext})
-  FILE(WRITE ${_script} ${_env}${CMDS})
+  FILE(APPEND ${_script} "${CMDS}")
 
   # 7. Create custom target
   ADD_CUSTOM_TARGET(${MULTI_LANG_TARGET_NAME}