File: install_test_cmake

package info (click to toggle)
modules 5.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,492; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (117 lines) | stat: -rwxr-xr-x 3,777 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#
# INSTALL_TEST_CMAKE, cmake test script for install non-reg suite
# Copyright (C) 2017-2021 Xavier Delaruelle
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

##########################################################################

cmake_policy(SET CMP0007 NEW)

if(NOT EXISTS ${initfile})
   message(FATAL_ERROR "Cannot read ${initfile}")
endif()

# source module init file
include(${initfile})

# execute command list
set(code 0)
set(runml 0)
string(REPLACE ":" ";" cmdsplit "${cmdlist}")
# empty command list, means one empty command
list (LENGTH cmdlist cmdcnt)
if(${cmdcnt} EQUAL 0)
   module("")
else()
   foreach(cmd ${cmdsplit})
      # call ml procedure instead of module
      if("${cmd}" STREQUAL "ml")
         set(runml 1)
      # if command equals to NOARG string, means call with no arg passed
      elseif("${cmd}" STREQUAL "NOARG")
         if (${runml} EQUAL 0)
            module()
         else()
            ml()
         endif()
      else()
         string(REPLACE "," ";" cmdelt "${cmd}")
         list (LENGTH cmdelt eltcnt)
         if(${eltcnt} GREATER 4)
            list(GET cmdelt 0 elt0)
            list(GET cmdelt 1 elt1)
            list(GET cmdelt 2 elt2)
            list(GET cmdelt 3 elt3)
            list(GET cmdelt 4 elt4)
            if (${runml} EQUAL 0)
               module("${elt0}" "${elt1}" "${elt2}" "${elt3}" "${elt4}")
            else()
               ml("${elt0}" "${elt1}" "${elt2}" "${elt3}" "${elt4}")
            endif()
         elseif(${eltcnt} GREATER 3)
            list(GET cmdelt 0 elt0)
            list(GET cmdelt 1 elt1)
            list(GET cmdelt 2 elt2)
            list(GET cmdelt 3 elt3)
            if (${runml} EQUAL 0)
               module("${elt0}" "${elt1}" "${elt2}" "${elt3}")
            else()
               ml("${elt0}" "${elt1}" "${elt2}" "${elt3}")
            endif()
         elseif(${eltcnt} GREATER 2)
            list(GET cmdelt 0 elt0)
            list(GET cmdelt 1 elt1)
            list(GET cmdelt 2 elt2)
            if (${runml} EQUAL 0)
               module("${elt0}" "${elt1}" "${elt2}")
            else()
               ml("${elt0}" "${elt1}" "${elt2}")
            endif()
         elseif(${eltcnt} GREATER 1)
            list(GET cmdelt 0 elt0)
            list(GET cmdelt 1 elt1)
            if (${runml} EQUAL 0)
               module("${elt0}" "${elt1}")
            else()
               ml("${elt0}" "${elt1}")
            endif()
         elseif(${eltcnt} GREATER 0)
            list(GET cmdelt 0 elt0)
            if (${runml} EQUAL 0)
               module("${elt0}")
            else()
               ml("${elt0}")
            endif()
         else()
            # empty arg list, means one empty arg
            if (${runml} EQUAL 0)
               module("")
            else()
               ml("")
            endif()
         endif()
      endif()
      if(NOT module_result AND NOT ${module_result} STREQUAL "")
         set(code 1)
      elseif(NOT ${module_result} STREQUAL "TRUE")
         message(STATUS ${module_result})
      endif()
   endforeach()
endif()

if(${code})
   message(FATAL_ERROR "")
endif()
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: