Project

General

Profile

« Previous | Next » 

Revision 952e86fa

Added by Bourbouh almost 7 years ago

add helpful_functions to the modules folder

View differences:

regression_tests/CMakeLists.txt
7 7
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/modules)
8 8
include(./modules/Lustre_compile.cmake)
9 9
include(./modules/Zustre_compile.cmake)
10
include(/home/ploc/Local/share/helpful_functions.cmake)
10
include(./modules/helpful_functions.cmake)
11 11
include(./modules/strategies.cmake)
12 12

  
13 13
if(LUSTRE_COMPILER)
regression_tests/modules/Lustre_compile.cmake
26 26
# The VERBOSE level is a numeric value passed directly to the -verbose
27 27
# command line option of the lustre compiler
28 28
#
29
include (/home/ploc/Local/share/helpful_functions.cmake)
29
include (./modules/helpful_functions.cmake)
30 30

  
31 31

  
32 32
if(LUSTRE_PATH_HINT)
regression_tests/modules/helpful_functions.cmake
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()

Also available in: Unified diff