File: EnvModules.cmake

package info (click to toggle)
cmake 4.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,344 kB
  • sloc: ansic: 403,894; cpp: 303,807; sh: 4,097; python: 3,582; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 108; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (33 lines) | stat: -rw-r--r-- 852 bytes parent folder | download | duplicates (6)
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
find_package(EnvModules REQUIRED)
message("module purge")
env_module(COMMAND purge RESULT_VARIABLE ret_var)
if(NOT ret_var EQUAL 0)
  message(FATAL_ERROR "module(purge) returned ${ret_var}")
endif()

message("module avail")
env_module_avail(avail_mods)
foreach(mod IN LISTS avail_mods)
  message("  ${mod}")
endforeach()

if(avail_mods)
  list(GET avail_mods 0 mod0)
  message("module load ${mod0}")
  env_module(load ${mod0})

  message("module list")
  env_module_list(loaded_mods)
  set(mod0_found FALSE)
  foreach(mod IN LISTS loaded_mods)
    message("  ${mod}")
    if(NOT mod0_found AND mod MATCHES "^${mod0}")
      set(mod0_found ${mod})
    endif()
  endforeach()

  if(NOT mod0_found)
    message(FATAL_ERROR "Requested module ${mod0} not found in loaded modules")
  endif()
  message("module ${mod0} found loaded as ${mod0_found}")
endif()