| 1 |
# |
| 2 |
# INSTALL_TEST_CMAKE, cmake test script for install non-reg suite |
| 3 |
# Copyright (C) 2017-2021 Xavier Delaruelle |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 2 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
########################################################################## |
| 19 |
|
| 20 |
cmake_policy(SET CMP0007 NEW) |
| 21 |
|
| 22 |
if(NOT EXISTS ${initfile}) |
| 23 |
message(FATAL_ERROR "Cannot read ${initfile}") |
| 24 |
endif() |
| 25 |
|
| 26 |
# source module init file |
| 27 |
include(${initfile}) |
| 28 |
|
| 29 |
# execute command list |
| 30 |
set(code 0) |
| 31 |
set(runml 0) |
| 32 |
string(REPLACE ":" ";" cmdsplit "${cmdlist}") |
| 33 |
# empty command list, means one empty command |
| 34 |
list (LENGTH cmdlist cmdcnt) |
| 35 |
if(${cmdcnt} EQUAL 0) |
| 36 |
module("") |
| 37 |
else() |
| 38 |
foreach(cmd ${cmdsplit}) |
| 39 |
# call ml procedure instead of module |
| 40 |
if("${cmd}" STREQUAL "ml") |
| 41 |
set(runml 1) |
| 42 |
# if command equals to NOARG string, means call with no arg passed |
| 43 |
elseif("${cmd}" STREQUAL "NOARG") |
| 44 |
if (${runml} EQUAL 0) |
| 45 |
module() |
| 46 |
else() |
| 47 |
ml() |
| 48 |
endif() |
| 49 |
else() |
| 50 |
string(REPLACE "," ";" cmdelt "${cmd}") |
| 51 |
list (LENGTH cmdelt eltcnt) |
| 52 |
if(${eltcnt} GREATER 4) |
| 53 |
list(GET cmdelt 0 elt0) |
| 54 |
list(GET cmdelt 1 elt1) |
| 55 |
list(GET cmdelt 2 elt2) |
| 56 |
list(GET cmdelt 3 elt3) |
| 57 |
list(GET cmdelt 4 elt4) |
| 58 |
if (${runml} EQUAL 0) |
| 59 |
module("${elt0}" "${elt1}" "${elt2}" "${elt3}" "${elt4}") |
| 60 |
else() |
| 61 |
ml("${elt0}" "${elt1}" "${elt2}" "${elt3}" "${elt4}") |
| 62 |
endif() |
| 63 |
elseif(${eltcnt} GREATER 3) |
| 64 |
list(GET cmdelt 0 elt0) |
| 65 |
list(GET cmdelt 1 elt1) |
| 66 |
list(GET cmdelt 2 elt2) |
| 67 |
list(GET cmdelt 3 elt3) |
| 68 |
if (${runml} EQUAL 0) |
| 69 |
module("${elt0}" "${elt1}" "${elt2}" "${elt3}") |
| 70 |
else() |
| 71 |
ml("${elt0}" "${elt1}" "${elt2}" "${elt3}") |
| 72 |
endif() |
| 73 |
elseif(${eltcnt} GREATER 2) |
| 74 |
list(GET cmdelt 0 elt0) |
| 75 |
list(GET cmdelt 1 elt1) |
| 76 |
list(GET cmdelt 2 elt2) |
| 77 |
if (${runml} EQUAL 0) |
| 78 |
module("${elt0}" "${elt1}" "${elt2}") |
| 79 |
else() |
| 80 |
ml("${elt0}" "${elt1}" "${elt2}") |
| 81 |
endif() |
| 82 |
elseif(${eltcnt} GREATER 1) |
| 83 |
list(GET cmdelt 0 elt0) |
| 84 |
list(GET cmdelt 1 elt1) |
| 85 |
if (${runml} EQUAL 0) |
| 86 |
module("${elt0}" "${elt1}") |
| 87 |
else() |
| 88 |
ml("${elt0}" "${elt1}") |
| 89 |
endif() |
| 90 |
elseif(${eltcnt} GREATER 0) |
| 91 |
list(GET cmdelt 0 elt0) |
| 92 |
if (${runml} EQUAL 0) |
| 93 |
module("${elt0}") |
| 94 |
else() |
| 95 |
ml("${elt0}") |
| 96 |
endif() |
| 97 |
else() |
| 98 |
# empty arg list, means one empty arg |
| 99 |
if (${runml} EQUAL 0) |
| 100 |
module("") |
| 101 |
else() |
| 102 |
ml("") |
| 103 |
endif() |
| 104 |
endif() |
| 105 |
endif() |
| 106 |
if(NOT module_result AND NOT ${module_result} STREQUAL "") |
| 107 |
set(code 1) |
| 108 |
elseif(NOT ${module_result} STREQUAL "TRUE") |
| 109 |
message(STATUS ${module_result}) |
| 110 |
endif() |
| 111 |
endforeach() |
| 112 |
endif() |
| 113 |
|
| 114 |
if(${code}) |
| 115 |
message(FATAL_ERROR "") |
| 116 |
endif() |
| 117 |
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |