From 325531fead7fc173983fda6faa2ed56d9b09ce13 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 25 Oct 2013 05:40:39 +0000 Subject: [PATCH] Add macro to accumulate environment variables --- SalomeKERNELConfig.cmake.in | 5 ++- salome_adm/cmake_files/FindSalomeKERNEL.cmake | 4 ++ salome_adm/cmake_files/SalomeMacros.cmake | 37 +++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/SalomeKERNELConfig.cmake.in b/SalomeKERNELConfig.cmake.in index 6a51c6b8a..ac65b28b5 100644 --- a/SalomeKERNELConfig.cmake.in +++ b/SalomeKERNELConfig.cmake.in @@ -51,6 +51,9 @@ SET_AND_CHECK(KERNEL_INCLUDE_DIRS "${KERNEL_ROOT_DIR_EXP}/@SALOME_INSTALL_HEADER SET(KERNEL_INCLUDE_DIRS "${KERNEL_INCLUDE_DIRS};@_SalomeKERNEL_EXTRA_HEADERS@") SET(KERNEL_DEFINITIONS) +# Package specific environment variables +@_SalomeKERNEL_EXTRA_ENV_FULL@ + #### Now the specificities # Options exported by the package: @@ -180,5 +183,3 @@ SET(KERNEL_TOOLSDS TOOLSDS) SET(KERNEL_UtilsTest UtilsTest) SET(KERNEL_with_loggerTraceCollector with_loggerTraceCollector) SET(KERNEL_SalomeKernelHelpers SalomeKernelHelpers) - - diff --git a/salome_adm/cmake_files/FindSalomeKERNEL.cmake b/salome_adm/cmake_files/FindSalomeKERNEL.cmake index 0f0ff81fc..fcfb7756b 100644 --- a/salome_adm/cmake_files/FindSalomeKERNEL.cmake +++ b/salome_adm/cmake_files/FindSalomeKERNEL.cmake @@ -47,3 +47,7 @@ SALOME_FIND_PACKAGE(SalomeKERNEL SalomeKERNEL CONFIG) IF(NOT SalomeKERNEL_FIND_QUIETLY) MESSAGE(STATUS "Found Salome KERNEL: ${KERNEL_ROOT_DIR}") ENDIF() + +FOREACH(_res ${SalomeKERNEL_EXTRA_ENV}) + SALOME_ACCUMULATE_ENVIRONMENT(${_res} "${SalomeKERNEL_EXTRA_ENV_${_res}}") +ENDFOREACH() diff --git a/salome_adm/cmake_files/SalomeMacros.cmake b/salome_adm/cmake_files/SalomeMacros.cmake index 29bca1f9f..ef8d8a3f1 100755 --- a/salome_adm/cmake_files/SalomeMacros.cmake +++ b/salome_adm/cmake_files/SalomeMacros.cmake @@ -636,3 +636,40 @@ MACRO(SALOME_ACCUMULATE_HEADERS lst) ENDIF() ENDFOREACH() ENDMACRO(SALOME_ACCUMULATE_HEADERS) + +######################################################################### +# SALOME_ACCUMULATE_ENVIRONMENT() +# +# USAGE: SALOME_ACCUMULATE_ENVIRONMENT(var value) +# +# ARGUMENTS: +# var [in] environment variable name, e.g. PATH +# value [in] value(s) to be added to environment variable +# +# This macro is called in the various FindSalomeXYZ.cmake modules to +# accumulate environment variables, to be used later to run some command +# in proper environment. +# +# 1. Each envrironment variable is stored in specific CMake variable +# _${PROJECT_NAME}_EXTRA_ENV_ +# where is name of variable. +# 2. Full list of environment variable names is stored in CMake variable +# _${PROJECT_NAME}_EXTRA_ENV. +# +MACRO(SALOME_ACCUMULATE_ENVIRONMENT envvar val) + FOREACH(_item ${val}) + LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res) + IF(_res EQUAL -1) + LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item}) + ENDIF() + ENDFOREACH() + LIST(FIND _${PROJECT_NAME}_EXTRA_ENV ${envvar} _res) + IF(_res EQUAL -1) + LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV ${envvar}) + ENDIF() + SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "SET\(${PROJECT_NAME}_EXTRA_ENV ${_${PROJECT_NAME}_EXTRA_ENV}\)") + FOREACH(_res ${_${PROJECT_NAME}_EXTRA_ENV}) + SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "${_${PROJECT_NAME}_EXTRA_ENV_FULL}\nSET\(${PROJECT_NAME}_EXTRA_ENV_${_res} ${_${PROJECT_NAME}_EXTRA_ENV_${_res}}\)") + ENDFOREACH() +ENDMACRO(SALOME_ACCUMULATE_ENVIRONMENT) + -- 2.39.2