Project

General

Profile

Revision 76bed200

View differences:

Makefile.in
77 77
	mkdir -p ${bindir}
78 78
	for x in $(BIN_TARGETS); do install -m 0755 $(LOCAL_BINDIR)/$$x ${bindir}; done
79 79
	mkdir -p ${datarootdir}
80
	install -m 0655 share/FindLustre.cmake ${datarootdir}
80
	install -m 0655 share/* ${datarootdir}
81 81
	mkdir -p ${includedir}/lustrec
82 82
	install -m 0655 include/* ${includedir}/lustrec
83 83

  
share/FindLustre.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 30

  
30 31
if(LUSTRE_PATH_HINT)
31 32
  message(STATUS "FindLustre: using PATH HINT: ${LUSTRE_PATH_HINT}")
......
103 104

  
104 105
  file(MAKE_DIRECTORY ${LUSTRE_OUTPUT_DIR})
105 106
  set(GLOBAL_LUSTRE_GENERATED_C_FILES "")
107
  set(GLOBAL_LUSTRE_DEP_C_FILES "")
106 108
  # create list of generated C files in parent scope
107 109
  set(LUSTRE_GENERATED_C_FILES_${LUS_LIBNAME} "" PARENT_SCOPE)
108 110
  foreach(LFILE IN LISTS LUS_LUS_FILES)
109
    get_filename_component(L ${LFILE} NAME_WE)
110
    get_filename_component(E ${LFILE} EXT)
111
    if ("${E}" STREQUAL ".lus")
111
    get_lustre_name_ext(${LFILE} L E)
112
    
113
    if ("${E}" STREQUAL "lus")
112 114
      set(LUSTRE_GENERATED_FILES ${LUSTRE_OUTPUT_DIR}/${L}.h ${LUSTRE_OUTPUT_DIR}/${L}.c ${LUSTRE_OUTPUT_DIR}/${L}_alloc.h)
115
      set(LUSTRE_DEP_FILES "")
113 116
      if(LUS_NODE)
114 117
         list(APPEND LUSTRE_GENERATED_FILES ${LUSTRE_OUTPUT_DIR}/${L}_main.c)
115
         list(APPEND LUSTRE_GENERATED_FILES ${LUSTRE_INCLUDE_DIR}/io_frontend.c)
118
         list(APPEND LUSTRE_DEP_FILES ${LUSTRE_INCLUDE_DIR}/io_frontend.c)
116 119
      endif()
117
    elseif("${E}" STREQUAL ".lusi")
120
    elseif("${E}" STREQUAL "lusi")
118 121
      set(LUSTRE_GENERATED_FILES ${LUSTRE_OUTPUT_DIR}/${L}.h)
119 122
    endif()
120 123
    list(APPEND GLOBAL_LUSTRE_GENERATED_C_FILES ${LUSTRE_GENERATED_FILES})
124
    list(APPEND GLOBAL_LUSTRE_DEP_FILES ${LUSTRE_DEP_FILES}) # todo: add if not already in the list
121 125
    set(LUSTRE_GENERATED_FILES ${LUSTRE_GENERATED_FILES} ${LUSTRE_OUTPUT_DIR}/${L}.lusic)
122 126
    if (LUS_LUSI)
123 127
      add_custom_command(
......
142 146
  include_directories(${LUSTRE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${LUSTRE_OUTPUT_DIR})
143 147
  if(LUS_NODE)
144 148
  add_executable(${LUS_LIBNAME}
145
              ${GLOBAL_LUSTRE_GENERATED_C_FILES} ${LUS_USER_C_FILES}
149
              ${GLOBAL_LUSTRE_GENERATED_C_FILES} ${GLOBAL_LUSTRE_DEP_FILES} ${LUS_USER_C_FILES}
146 150
              )
147 151
  else()
148 152
  add_library(${LUS_LIBNAME} SHARED
149
              ${GLOBAL_LUSTRE_GENERATED_C_FILES} ${LUS_USER_C_FILES}
153
              ${GLOBAL_LUSTRE_GENERATED_C_FILES} ${GLOBAL_LUSTRE_DEP_FILES} ${LUS_USER_C_FILES}
150 154
              )
151 155
  endif()
152 156
  set_target_properties(${LUS_LIBNAME} PROPERTIES COMPILE_FLAGS "-std=c99")
share/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