Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / share / helpful_functions.cmake @ 76bed200

History | View | Annotate | Download (1.63 KB)

1

    
2

    
3
#helpful functions and macros
4
MACRO(SUBDIRLIST result curdir REGEX_PREFIX)
5
  FILE(GLOB children RELATIVE ${curdir} ${curdir}/${REGEX_PREFIX}*)
6
  SET(dirlist "")
7
  FOREACH(child ${children})
8
    IF(IS_DIRECTORY ${curdir}/${child})
9
      LIST(APPEND dirlist ${child})
10
    ENDIF()
11
  ENDFOREACH()
12
  SET(${result} ${dirlist})
13
ENDMACRO()
14

    
15
MACRO(LUSTREFILES result dir)
16
  FILE(GLOB children ${dir} ${dir}/*.lus)
17
  SET(lustreFileslist "")
18
  FOREACH(child ${children})
19
    IF(EXISTS ${child} AND NOT IS_DIRECTORY ${child})
20
      LIST(APPEND lustreFileslist ${child})
21
    ENDIF()
22
  ENDFOREACH()
23
  SET(${result} ${lustreFileslist})
24
ENDMACRO()
25

    
26

    
27
function(JOIN VALUES GLUE OUTPUT)
28
  string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
29
  string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
30
  set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
31
endfunction()
32

    
33

    
34

    
35

    
36
function(CUT_OPTIONS ZUS_OPTS OUTPUT)
37
  string(REPLACE "--" "_" ZUS_OPTS_CUT ${ZUS_OPTS})
38
  string(REPLACE "-" "" ZUS_OPTS_CUT ${ZUS_OPTS_CUT})
39
  string(REPLACE " " "_" ZUS_OPTS_CUT ${ZUS_OPTS_CUT})
40
  set (${OUTPUT} "${ZUS_OPTS_CUT}" PARENT_SCOPE)
41
endfunction()
42

    
43
function(get_lustre_name_ext LUS_FILE L E)
44
  # Extraction name + extension from ${LUS_LUS_FILE} as L and E. E is the smallest extension
45
  get_filename_component(N ${LUS_FILE} NAME)
46
  string(REPLACE "." ";" N ${N})
47
  set(N "${N}")
48
  list(LENGTH N len)
49
  math(EXPR idx "${len}-1") 
50
  list(GET N "${idx}" "${E}")
51
  set(L "${N}")
52
  list(REMOVE_AT L "${idx}")
53
  string(REPLACE ";" "." L "${L}")
54
#  message("Extraction file ${LUS_FILE} as ${L} and ${E}")
55
  set(L "${L}" PARENT_SCOPE)
56
  set(E "${E}" PARENT_SCOPE)
57
endfunction()