Initial commit
This commit is contained in:
65
cmake/ModuleEnv.cmake
Normal file
65
cmake/ModuleEnv.cmake
Normal file
@@ -0,0 +1,65 @@
|
||||
#
|
||||
# Environment Module 环境模块生成脚本
|
||||
#
|
||||
|
||||
# 生成 module 环境文件
|
||||
# MOD_NAME:模块名 SOFT_PATH:软件安装路径
|
||||
function(GenerateModule MOD_NAME MOD_VERS SOFT_PATH)
|
||||
set(MOD_FILE ${MODULES_ROOT}/${MOD_NAME}/${MOD_VERS})
|
||||
DEPLOY_MSG("Generate module name: ${MOD_NAME}")
|
||||
DEPLOY_MSG("Generate module vers: ${MOD_VERS}")
|
||||
DEPLOY_MSG("Generate module file: ${MOD_FILE}")
|
||||
|
||||
get_filename_component(MOD_DIR ${MOD_FILE} DIRECTORY)
|
||||
file(MAKE_DIRECTORY ${MOD_DIR})
|
||||
|
||||
string(TOUPPER ${MOD_NAME} MOD_NAME_UPPER)
|
||||
|
||||
# 写入 module 模板
|
||||
file(WRITE ${MOD_FILE}
|
||||
"#%Module1.0
|
||||
proc ModulesHelp { } {
|
||||
puts stderr \"Load ${MOD_NAME} environment\"
|
||||
}
|
||||
module-whatis \"Sets up software ${MOD_NAME} \"
|
||||
|
||||
set soft_name \"${MOD_NAME}\"
|
||||
set soft_vers \"${MOD_VERS}\"
|
||||
set soft_root \"${SOFT_PATH}\"
|
||||
|
||||
prepend-path PATH \$soft_root/bin
|
||||
|
||||
prepend-path LIBRARY_PATH \$soft_root/lib
|
||||
prepend-path LD_LIBRARY_PATH \$soft_root/lib
|
||||
|
||||
prepend-path LIBRARY_PATH \$soft_root/lib64
|
||||
prepend-path LD_LIBRARY_PATH \$soft_root/lib64
|
||||
|
||||
prepend-path CPATH \$soft_root/include
|
||||
prepend-path MANPATH \$soft_root/share/man
|
||||
prepend-path PKG_CONFIG_PATH \$soft_root/lib/pkgconfig
|
||||
|
||||
setenv ${MOD_NAME_UPPER}_HOME \$soft_root
|
||||
|
||||
if { \[ module-info mode load \] } {
|
||||
puts stderr \"\${soft_name}_name: \$soft_name - \$soft_vers\"
|
||||
puts stderr \"\${soft_name}_root: \$soft_root\"
|
||||
}
|
||||
")
|
||||
|
||||
if(MOD_NAME STREQUAL "openmpi")
|
||||
file(APPEND ${MOD_FILE}
|
||||
"
|
||||
setenv OMPI_ALLOW_RUN_AS_ROOT 1
|
||||
setenv OMPI_ALLOW_RUN_AS_ROOT_CONFIRM 1
|
||||
")
|
||||
endif()
|
||||
|
||||
if(MOD_NAME STREQUAL "fftw")
|
||||
file(APPEND ${MOD_FILE}
|
||||
"
|
||||
setenv OMPI_ALLOW_RUN_AS_ROOT 0
|
||||
setenv OMPI_ALLOW_RUN_AS_ROOT_CONFIRM 0
|
||||
")
|
||||
endif()
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user