From a69080e79f15ef6bdb5fb982405307a2762e57a7 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 5 Nov 2013 11:26:27 +0000 Subject: [PATCH] Fix bug with zero-length list processing --- SalomeKERNELConfig.cmake.in | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/SalomeKERNELConfig.cmake.in b/SalomeKERNELConfig.cmake.in index 2c5be26f8..a5e884660 100644 --- a/SalomeKERNELConfig.cmake.in +++ b/SalomeKERNELConfig.cmake.in @@ -109,26 +109,28 @@ SET(_PREREQ @_PREREQ_LIST@) SET(_PREREQ_CONFIG_DIR @_PREREQ_DIR_LIST@) SET(_PREREQ_COMPONENTS "@_PREREQ_COMPO_LIST@") LIST(LENGTH _PREREQ_CONFIG_DIR _list_len) -# Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ... -MATH(EXPR _range "${_list_len}-1") -FOREACH(_p RANGE ${_range}) - LIST(GET _PREREQ ${_p} _pkg ) - LIST(GET _PREREQ_CONFIG_DIR ${_p} _pkg_dir) - LIST(GET _PREREQ_COMPONENTS ${_p} _pkg_compo) - MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...") - IF(NOT _pkg_compo) - FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE +IF(NOT _list_len EQUAL 0) + # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ... + MATH(EXPR _range "${_list_len}-1") + FOREACH(_p RANGE ${_range}) + LIST(GET _PREREQ ${_p} _pkg ) + LIST(GET _PREREQ_CONFIG_DIR ${_p} _pkg_dir) + LIST(GET _PREREQ_COMPONENTS ${_p} _pkg_compo) + MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...") + IF(NOT _pkg_compo) + FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE PATHS "${_pkg_dir}" NO_DEFAULT_PATH) - ELSE() - STRING(REPLACE "," ";" _compo_lst "${_pkg_compo}") - MESSAGE(STATUS "===> (components: ${_pkg_compo})") - FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE + ELSE() + STRING(REPLACE "," ";" _compo_lst "${_pkg_compo}") + MESSAGE(STATUS "===> (components: ${_pkg_compo})") + FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE COMPONENTS ${_compo_lst} PATHS "${_pkg_dir}" NO_DEFAULT_PATH) - ENDIF() -ENDFOREACH() + ENDIF() + ENDFOREACH() +ENDIF() # Installation directories SET(SALOME_INSTALL_BINS "@SALOME_INSTALL_BINS@") -- 2.39.2