# 2. Full list of environment variable names is stored in CMake variable
# _${PROJECT_NAME}_EXTRA_ENV.
#
+# Notes:
+# - If in arguments is set keyword CHECK all argument after checked for directory,
+# else if NOT_CHECK macro accumulates arguments without checking.
+# By default all arguments without keyword must be checked.
+#
MACRO(SALOME_ACCUMULATE_ENVIRONMENT envvar)
+ SET(_is_check ON)
FOREACH(_item ${ARGN})
- IF(EXISTS ${_item})
- IF(IS_DIRECTORY ${_item})
+ IF(${_item} STREQUAL "NOT_CHECK")
+ SET(_is_check OFF)
+ ELSEIF(${_item} STREQUAL "CHECK")
+ SET(_is_check ON)
+ ELSE()
+ IF(_is_check)
+ IF(NOT IS_DIRECTORY ${_item})
+ IF(TARGET ${_item})
+ GET_TARGET_PROPERTY(_item ${_item} LOCATION)
+ ENDIF()
+ GET_FILENAME_COMPONENT(_item ${_item} PATH)
+ ENDIF()
+ IF(EXISTS ${_item})
+ STRING(REGEX MATCH "^/usr" _usr_find ${_item})
+ LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res)
+ IF(NOT _usr_find AND _res EQUAL -1)
+ LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item})
+ ENDIF()
+ ENDIF()
+ ELSE(_is_check)
LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res)
- IF(_res EQUAL -1)
+ IF( _res EQUAL -1)
LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item})
- ENDIF()
- ELSE()
- GET_FILENAME_COMPONENT(_path_dir ${_item} PATH)
- LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_path_dir} _res)
- IF(_res EQUAL -1)
- LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_path_dir})
- ENDIF()
- ENDIF()
- ENDIF()
+ ENDIF()
+ ENDIF(_is_check)
+ ENDIF()
ENDFOREACH()
+
LIST(FIND _${PROJECT_NAME}_EXTRA_ENV ${envvar} _res)
IF(_res EQUAL -1)
LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV ${envvar})