Project

General

Profile

Download (5.55 KB) Statistics
| Branch: | Tag: | Revision:
1
# - Find Lustre compiler
2
# Find the Lustre synchronous language compiler with associated includes path.
3
# See https://cavale.enseeiht.fr/redmine/projects/lustrec
4
# This module defines
5
#  LUSTRE_COMPILER, the lustre compiler
6
#  LUSTRE_COMPILER_VERSION, the version of the lustre compiler
7
#  LUSTRE_INCLUDE_DIR, where to find dword.h, etc.
8
#  LUSTRE_FOUND, If false, Lustre was not found.
9
# On can set LUSTRE_PATH_HINT before using find_package(Lustre) and the
10
# module with use the PATH as a hint to find lustrec.
11
#
12
# The hint can be given on the command line too:
13
#   cmake -DLUSTRE_PATH_HINT=/DATA/ERIC/Lustre/lustre-x.y /path/to/source
14
#
15
# The module defines some functions:
16
#   Lustre_Compile([NODE <Lustre Main Node>]
17
#                  LUS_FILE <Lustre file>
18
#                  [USER_C_FILES <C files>]
19
#                  [VERBOSE <level>]
20
#		   [OPTIONS <options>]
21
#				[DIR <directory dest>])
22
#
23
# When used the Lustre_Compile macro define the variable
24
# LUSTRE_GENERATED_C_FILES_<libraryName> in the parent scope
25
# so that the caller can get (if needed) the list of Lustre generated files.
26
# The VERBOSE level is a numeric value passed directly to the -verbose
27
# command line option of the lustre compiler
28
#
29
include (./modules/helpful_functions.cmake)
30

    
31

    
32
if(LUSTRE_PATH_HINT)
33
  message(STATUS "FindLustre: using PATH HINT: ${LUSTRE_PATH_HINT}")
34
else()
35
  set(LUSTRE_PATH_HINT)
36
endif()
37

    
38

    
39
# FIND_PROGRAM twice using NO_DEFAULT_PATH on first shot
40
find_program(LUSTRE_COMPILER
41
  NAMES lustrec
42
  HINTS ${LUSTRE_PATH_HINT}
43
  PATH_SUFFIXES bin
44
  DOC "Path to the Lustre compiler command 'lustrec'")
45

    
46
find_program(LUSTRE_COMPILER
47
  NAMES lustrec
48
  PATHS ${LUSTRE_PATH_HINT}
49
  PATH_SUFFIXES bin
50
  NO_DEFAULT_PATH
51
  DOC "Path to the Lustre compiler command 'lustrec'")
52

    
53

    
54
if(LUSTRE_COMPILER)
55
    # get the path where the lustre compiler was found
56
    get_filename_component(LUSTRE_PATH ${LUSTRE_COMPILER} PATH)
57
    # remove bin
58
    get_filename_component(LUSTRE_PATH ${LUSTRE_PATH} PATH)
59
    # add path to LUSTRE_PATH_HINT
60
    list(APPEND LUSTRE_PATH_HINT ${LUSTRE_PATH})
61
    execute_process(COMMAND ${LUSTRE_COMPILER} -version
62
        OUTPUT_VARIABLE LUSTRE_COMPILER_VERSION
63
        OUTPUT_STRIP_TRAILING_WHITESPACE)
64
    message(STATUS "Lustre compiler version is : ${LUSTRE_COMPILER_VERSION}")
65
endif(LUSTRE_COMPILER)
66

    
67

    
68
find_path(LUSTRE_INCLUDE_DIR
69
          NAMES arrow.h
70
          PATHS ${LUSTRE_PATH_HINT}
71
          PATH_SUFFIXES include/lustrec
72
          DOC "The Lustre include headers")
73

    
74
find_program(LUSTRE_T
75
  NAMES lustret
76
  HINTS ${LUSTRE_PATH_HINT}
77
  PATH_SUFFIXES bin
78
  DOC "Path to the Lustre compiler command 'lustret'")
79

    
80
find_program(LUSTRE_T
81
  NAMES lustret
82
  PATHS ${LUSTRE_PATH_HINT}
83
  PATH_SUFFIXES bin
84
  NO_DEFAULT_PATH
85
  DOC "Path to the Lustre compiler command 'lustret'")
86

    
87
	
88
# Macros used to compile a lustre library
89
include(CMakeParseArguments)
90
function(Lustre_Compile)
91
  set(options "")
92
  set(oneValueArgs  NODE VERBOSE LUS_FILE DIR DST_DIR)
93
  set(multiValueArgs  OPTS USER_C_FILES )
94
  cmake_parse_arguments(LUS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
95

    
96

    
97
  get_lustre_name_ext(${LUS_LUS_FILE} L E)
98
  
99
  # get_filename_component(L ${LUS_LUS_FILE} NAME_WE)
100
  # get_filename_component(E ${LUS_LUS_FILE} EXT)
101
  set(LUSTREC_ARGS "")
102

    
103
  if(LUS_DST_DIR)
104
    set(OUTPUT_PATH "${LUS_DST_DIR}")
105
  else()
106
    set(OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
107
  endif()
108

    
109
  if(LUS_NODE)
110
    set(LUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}/node_${LUS_NODE}")
111
    set(LUSTREC_ARGS ${LUSTREC_ARGS} -node ${LUS_NODE} )
112
  else()
113
    set(LUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}")
114
  endif()
115
 
116
  
117
  if(LUS_OPTS)
118
    CUT_OPTIONS("${LUS_OPTS}" LUS_OPTS_CUT)
119
    if(LUS_NODE)
120
	set(LUSTRE_OUTPUT_DIR "${LUSTRE_OUTPUT_DIR}_${LUS_OPTS_CUT}")
121
    else(LUS_NODE)
122
	set(LUSTRE_OUTPUT_DIR "${LUSTRE_OUTPUT_DIR}/${LUS_OPTS_CUT}")
123
    endif(LUS_NODE)
124
	set(LUSTREC_ARGS ${LUSTREC_ARGS} ${LUS_OPTS} )
125
  endif(LUS_OPTS)
126

    
127
  if (LUS_VERBOSE)
128
    set(LUSTRE_VERBOSE_OPT "-verbose ${LUS_VERBOSE}")
129
    set(LUSTREC_ARGS ${LUSTREC_ARGS} -verbose ${LUS_VERBOSE} )
130
  endif()
131
  
132
  
133
  set(LUSTRE_GENERATED_FILES "")
134
  file(MAKE_DIRECTORY ${LUSTRE_OUTPUT_DIR})
135
  # create list of generated C files in parent scope
136
  if ("${E}" STREQUAL ".lus")
137
	set(LUSTRE_GENERATED_FILES ${LUSTRE_OUTPUT_DIR}/${L}.h   ${LUSTRE_OUTPUT_DIR}/${L}.lusic )
138
	if (LUS_NODE)
139
		set(LUSTRE_GENERATED_FILES ${LUSTRE_GENERATED_FILES} ${LUSTRE_OUTPUT_DIR}/${L}.c ${LUSTRE_OUTPUT_DIR}/${L}_alloc.h ${LUSTRE_OUTPUT_DIR}/${L}_main.c ${LUSTRE_OUTPUT_DIR}/${L}.makefile)
140
	endif(LUS_NODE)
141
	if(LUS_OPTS MATCHES "horn")
142
		set(LUSTRE_GENERATED_FILES ${LUSTRE_GENERATED_FILES} ${LUSTRE_OUTPUT_DIR}/${L}.smt2)
143
	endif(LUS_OPTS MATCHES "horn")
144
  elseif("${E}" STREQUAL ".lusi")
145
	set(LUSTRE_GENERATED_FILES ${LUSTRE_OUTPUT_DIR}/${L}.h)
146
  endif()
147
  
148
  if(LUS_DIR)
149
	set(LUSTRE_OUTPUT_DIR ${LUS_DIR} )
150
  endif()
151
  set(LUSTREC_ARGS ${LUSTREC_ARGS} -d ${LUSTRE_OUTPUT_DIR} ${LUS_LUS_FILE})
152
 
153
  set(LUSTREC_ARGS_${L}_${LUS_NODE}_${LUS_OPTS_CUT} "${LUSTREC_ARGS}" PARENT_SCOPE)
154
  set(LUSTRE_GENERATED_FILES_${L}_${LUS_NODE}_${LUS_OPTS_CUT} "${LUSTRE_GENERATED_FILES}" PARENT_SCOPE)
155
  set(LUSTRE_OUTPUT_DIR_${L}_${LUS_NODE}_${LUS_OPTS_CUT} "${LUSTRE_OUTPUT_DIR}" PARENT_SCOPE)
156
endfunction(Lustre_Compile)
157

    
158
# handle the QUIETLY and REQUIRED arguments and set LUSTRE_FOUND to TRUE if
159
# all listed variables are TRUE
160
include(FindPackageHandleStandardArgs)
161
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LUSTRE
162
                                  REQUIRED_VARS LUSTRE_COMPILER LUSTRE_INCLUDE_DIR)
163
# VERSION FPHSA options not handled by CMake version < 2.8.2)
164
#                                  VERSION_VAR LUSTRE_COMPILER_VERSION)
165
mark_as_advanced(LUSTRE_INCLUDE_DIR)
(2-2/10)