]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
This is alternative solution for improvement "0023066: [CEA 1509] CMake - Installatio... mpa/23066
authormpa <mpa@opencascade.com>
Tue, 14 Jul 2015 11:50:50 +0000 (14:50 +0300)
committermpa <mpa@opencascade.com>
Tue, 14 Jul 2015 11:50:50 +0000 (14:50 +0300)
For usage, these changes must be implemented for all Salome modules.

CMakeLists.txt
salome_adm/cmake_files/FindSalomeKERNEL.cmake
salome_adm/cmake_files/SalomeMacros.cmake

index 403a9329919d8209e2e9f9c484dca4159f2648fd..f4583e16db5f51c979e25fe5e54aeb498cfd12dc 100755 (executable)
@@ -175,10 +175,10 @@ MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_KERNE
 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG SALOME_INSTALL_AMCONFIG_LOCAL)
 
 # Accumulate environment variables for KERNEL module
-SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
-                                                 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
-                                                 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
-SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
+INSERT_INTO_MAP(${PROJECT_NAME}_OWN_ENV PYTHONPATH ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
+                                                   ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
+                                                   ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
+INSERT_INTO_MAP(${PROJECT_NAME}_OWN_ENV LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
 
 # For salome test
 SET(KERNEL_TEST_DIR ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test)
@@ -322,3 +322,8 @@ INSTALL(FILES
 # Install the export set for use with the install-tree
 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
         FILE ${PROJECT_NAME}Targets.cmake)
+        
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+MESSAGE("tests_env = ${tests_env}")
+
+SALOME_GENERATE_ENVIRONMENT_SCRIPT(plugins_cmd env_script "${PYTHON_EXECUTABLE}" "${plugins_cmd_options}")
index d107285330b08633a17e4445e7e6406a072f705e..16f5f3c6daf8522e189a721db5044ee3a34d342c 100644 (file)
@@ -51,6 +51,11 @@ ENDIF()
 FOREACH(_res ${SalomeKERNEL_EXTRA_ENV})
   SALOME_ACCUMULATE_ENVIRONMENT(${_res} "${SalomeKERNEL_EXTRA_ENV_${_res}}")
 ENDFOREACH()
+# Accumulate own environment variables
+SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${CMAKE_PREFIX_PATH}/${SALOME_INSTALL_BINS}
+                                         ${CMAKE_PREFIX_PATH}/${SALOME_INSTALL_PYTHON}
+                                         ${CMAKE_PREFIX_PATH}/${SALOME_INSTALL_PYTHON_SHARED})
+SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${CMAKE_PREFIX_PATH}/${SALOME_INSTALL_LIBS})
 
 #----------------------------------------------------------------------------
 # KERNEL_WITH_CORBA is a macro useful for determining whether a KERNEL module 
index 7ed262265b68421ec63967f72a07d5c406c49375..07040086fcb6b21009306d93b373efc76f3cd00c 100644 (file)
@@ -793,16 +793,19 @@ MACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT output script cmd opts)
   ENDIF()
   
   SET(_env)
-  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")        
-      ELSE(WIN32)
-        SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
-      ENDIF(WIN32)
+  SET(_env_vars ${PROJECT_NAME}_OWN_ENV _${PROJECT_NAME}_EXTRA_ENV)
+  FOREACH(_list ${_env_vars})
+    FOREACH(_item ${${_list}})
+      FOREACH(_val ${${_list}_${_item}})
+        IF(WIN32)
+          IF(${_item} STREQUAL "LD_LIBRARY_PATH")
+            SET(_item PATH)
+          ENDIF()
+          STRING(REPLACE "/" "\\" _env "${_env} @SET ${_item}=${_val};%${_item}%\n")        
+        ELSE(WIN32)
+          SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
+        ENDIF(WIN32)
+      ENDFOREACH()
     ENDFOREACH()
   ENDFOREACH()
   
@@ -828,61 +831,66 @@ ENDMACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT)
 # and puts this variable into <output> argument.
 #
 MACRO(SALOME_GENERATE_TESTS_ENVIRONMENT output)
- SET(_env)
- SET(_WIN_LD_LIBRARY OFF)
- FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
-   IF(${_item} STREQUAL "LD_LIBRARY_PATH")
-     SET(_WIN_LD_LIBRARY ON)
-   ENDIF()
-   SET(_env_${_item})
-   FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
-     IF(WIN32)
-       STRING(REPLACE "/" "\\" _val "${_val}")
-       SET(_env_${_item} "${_val};${_env_${_item}}")
-     ELSE()
-       SET(_env_${_item} "${_val}:${_env_${_item}}")
-     ENDIF()
-   ENDFOREACH()
- ENDFOREACH()
-
- IF(_WIN_LD_LIBRARY AND WIN32)
-   SET(_env_PATH "${_env_PATH}$ENV{LD_LIBRARY_PATH};${_env_LD_LIBRARY_PATH}")
- ENDIF()
-
- IF(WIN32)
-   SET(sep ",")
- ELSE()
-   SET(sep ";")
- ENDIF()
+  SET(_env)
+  SET(_WIN_LD_LIBRARY OFF)
+  SET(_env_vars ${PROJECT_NAME}_OWN_ENV _${PROJECT_NAME}_EXTRA_ENV)
+  FOREACH(_list ${_env_vars})
+    FOREACH(_item ${${_list}})
+      IF(${_item} STREQUAL "LD_LIBRARY_PATH")
+        SET(_WIN_LD_LIBRARY ON)
+      ENDIF()
+      SET(_env_${_list}_${_item})
+      FOREACH(_val ${${_list}_${_item}})
+        IF(WIN32)
+          STRING(REPLACE "/" "\\" _val "${_val}")
+          SET(_env_${_list}_${_item} "${_val};${_env_${_list}_${_item}}")
+        ELSE()
+          SET(_env_${_list}_${_item} "${_val}:${_env_${_list}_${_item}}")
+        ENDIF()
+      ENDFOREACH()
+    ENDFOREACH()
+  ENDFOREACH()
+
+  IF(_WIN_LD_LIBRARY AND WIN32)
+    SET(_env_PATH "${_env_PATH}$ENV{LD_LIBRARY_PATH};${_env_LD_LIBRARY_PATH}")
+  ENDIF()
+
+  IF(WIN32)
+    SET(sep ",")
+  ELSE()
+    SET(sep ";")
+  ENDIF()
  
- FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
-   IF(WIN32)
-     IF(NOT ${_item} STREQUAL "LD_LIBRARY_PATH")
-       SET(_env "${_item}=$ENV{${_item}};${_env_${_item}}${sep}${_env}")
-     ENDIF()
-   ELSE()
-     STRING(REPLACE ";" ":" _iii "$ENV{${_item}}")
-     SET(_env "${_item}=${_iii}:${_env_${_item}}${sep}${_env}")
-   ENDIF()
- ENDFOREACH()
-
- # Get module name as substring of "Salome<ModuleName>"
- STRING(REGEX MATCH "^Salome" _is_salome_project ${PROJECT_NAME})
- IF(_is_salome_project)
-   STRING(SUBSTRING "${PROJECT_NAME}" 6 -1 PRNAME) 
- ELSE()
-   SET(PRNAME ${PROJECT_NAME})
- ENDIF()
- SET(_env "${PRNAME}_ROOT_DIR=${CMAKE_INSTALL_PREFIX}${sep}${_env}")
+  FOREACH(_list ${_env_vars})
+    FOREACH(_item ${${_list}})
+      IF(WIN32)
+        IF(NOT ${_item} STREQUAL "LD_LIBRARY_PATH")
+          SET(_env "${_item}=$ENV{${_item}};${_env_${_list}_${_item}}${sep}${_env}")
+        ENDIF()
+      ELSE()
+        STRING(REPLACE ";" ":" _iii "$ENV{${_item}}")
+        SET(_env "${_item}=${_iii}:${_env_${_list}_${_item}}${sep}${_env}")
+      ENDIF()
+    ENDFOREACH()
+  ENDFOREACH()
+
+  # Get module name as substring of "Salome<ModuleName>"
+  STRING(REGEX MATCH "^Salome" _is_salome_project ${PROJECT_NAME})
+  IF(_is_salome_project)
+    STRING(SUBSTRING "${PROJECT_NAME}" 6 -1 PRNAME) 
+  ELSE()
+    SET(PRNAME ${PROJECT_NAME})
+  ENDIF()
+  SET(_env "${PRNAME}_ROOT_DIR=${CMAKE_INSTALL_PREFIX}${sep}${_env}")
   
- # Creating follow string for Windows environement:
- # "VAR1_ENV=1\;2\;3\;...\;...\;...;VAR2_ENV=1\;2\;3\;...\;...\;...;VAR3_ENV=1\;2\;3\;...\;...\;...;..."
- IF(WIN32)
-   STRING(REGEX REPLACE "\\\\*;" "\\\\;" _env "${_env}")
-   STRING(REGEX REPLACE "\\\\*;*," ";" _env "${_env}")
- ENDIF()
 # Creating follow string for Windows environement:
 # "VAR1_ENV=1\;2\;3\;...\;...\;...;VAR2_ENV=1\;2\;3\;...\;...\;...;VAR3_ENV=1\;2\;3\;...\;...\;...;..."
 IF(WIN32)
+    STRING(REGEX REPLACE "\\\\*;" "\\\\;" _env "${_env}")
+    STRING(REGEX REPLACE "\\\\*;*," ";" _env "${_env}")
 ENDIF()
 
- SET(${output} "${_env}")
 SET(${output} "${_env}")
 
 ENDMACRO(SALOME_GENERATE_TESTS_ENVIRONMENT) 
 
@@ -942,3 +950,26 @@ MACRO(SALOME_CONFIGURE_PREPARE)
     ENDIF()
   ENDFOREACH()
 ENDMACRO(SALOME_CONFIGURE_PREPARE)
+
+#########################################################################
+# INSERT_INTO_MAP()
+# 
+# USAGE: INSERT_INTO_MAP(name key values)
+#
+# ARGUMENTS:
+#   name   [in] input name of map
+#   key    [in] input key of map
+#   values [in] input list of key values
+#
+# This macro emulates the creation of map [key]->[value]
+#
+MACRO(INSERT_INTO_MAP name key)
+  FOREACH(_value ${ARGN})
+    LIST(APPEND ${name}_${key} "${_value}")
+  ENDFOREACH()
+  LIST(FIND ${key} ${name} _res)
+  IF(_res EQUAL -1)
+    LIST(APPEND ${name} ${key})
+  ENDIF()
+ENDMACRO(INSERT_INTO_MAP)