Project

General

Profile

Download (4.08 KB) Statistics
| Branch: | Tag: | Revision:
1
# - Find Zustre compiler with associated includes path.
2
# See https://github.com/coco-team/zustre
3
# This module defines
4
#  ZUSTRE_COMPILER, the ZUStre compiler
5
#  ZUSTRE_COMPILER_VERSION, the version of the ZUStre compiler
6
#  ZUSTRE_INCLUDE_DIR, where to find dword.h, etc.
7
#  ZUSTRE_FOUND, If false, ZUStre was not found.
8
# On can set ZUSTRE_PATH_HINT before using find_package(Zustre) and the
9
# module with use the PATH as a hint to find zustre.
10
#
11
# The hint can be given on the command line too:
12
#   cmake -DZUSTRE_PATH_HINT=/DATA/Hamza/Zustre/zustre-x.y /path/to/source
13
#
14
# The module defines some functions:
15
#   Zustre_Compile([NODE <ZUStre Main Node>]
16
#                  LUS_FILE <ZUStre file>
17
#                  [VERBOSE <level>]
18
#		   [OPTIONS <options>])
19
#
20
#
21

    
22

    
23
if(ZUSTRE_PATH_HINT)
24
  message(STATUS "FindZustre: using PATH HINT: ${ZUSTRE_PATH_HINT}")
25
else()
26
  set(ZUSTRE_PATH_HINT)
27
endif()
28

    
29

    
30
# FIND_PROGRAM twice using NO_DEFAULT_PATH on first shot
31
find_program(ZUSTRE_COMPILER
32
  NAMES zustre
33
  PATHS ${ZUSTRE_PATH_HINT}
34
  PATH_SUFFIXES bin
35
  NO_DEFAULT_PATH
36
  DOC "Path to the Zustre compiler command 'zustre'")
37

    
38
find_program(ZUSTRE_COMPILER
39
  NAMES zustre
40
  PATHS ${ZUSTRE_PATH_HINT}
41
  PATH_SUFFIXES bin
42
  DOC "Path to the ZUStre compiler command 'zustre'")
43

    
44
if(ZUSTRE_COMPILER)
45
    # get the path where the zustre compiler was found
46
    get_filename_component(ZUSTRE_PATH ${ZUSTRE_COMPILER} PATH)
47
    # remove bin
48
    get_filename_component(ZUSTRE_PATH ${ZUSTRE_PATH} PATH)
49
    # add path to ZUSTRE_PATH_HINT
50
    list(APPEND ZUSTRE_PATH_HINT ${ZUSTRE_PATH})
51
endif(ZUSTRE_COMPILER)
52

    
53
find_path(ZUSTRE_INCLUDE_DIR
54
          NAMES z3.h
55
          PATHS ${ZUSTRE_PATH_HINT}
56
          PATH_SUFFIXES include
57
          DOC "The ZUStre include headers")
58

    
59
# Macros used to compile a ZUStre library
60
include(CMakeParseArguments)
61
function(Zustre_Compile)
62
  set(options "")
63
  set(oneValueArgs  NODE VERBOSE LUS_FILE DST_DIR)
64
  set(multiValueArgs  OPTS )
65
  cmake_parse_arguments(ZUS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
66

    
67

    
68
  get_filename_component(L ${ZUS_LUS_FILE} NAME_WE)
69
  get_filename_component(E ${ZUS_LUS_FILE} EXT)
70
  set(ZUSTRE_ARGS "")
71

    
72
  if(ZUS_DST_DIR)
73
    set(OUTPUT_PATH "${ZUS_DST_DIR}")
74
  else()
75
    set(OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
76
  endif()
77

    
78
  if(ZUS_NODE)
79
    set(ZUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}/node_${ZUS_NODE}")
80
    set(ZUSTRE_ARGS ${ZUSTRE_ARGS} --node ${ZUS_NODE} )
81
  else()
82
    set(ZUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}")
83
  endif()
84
 
85
  
86
  if(ZUS_OPTS)
87
    CUT_OPTIONS("${ZUS_OPTS}" ZUS_OPTS_CUT)
88
    if(ZUS_NODE)
89
		set(ZUSTRE_OUTPUT_DIR "${ZUSTRE_OUTPUT_DIR}_${ZUS_OPTS_CUT}")
90
    else()
91
		set(ZUSTRE_OUTPUT_DIR "${ZUSTRE_OUTPUT_DIR}/${ZUS_OPTS_CUT}")
92
	endif()
93
	set(ZUSTRE_ARGS ${ZUSTRE_ARGS} ${ZUS_OPTS} )
94
  endif()
95

    
96
  if (ZUS_VERBOSE)
97
    set(ZUSTRE_ARGS ${ZUSTRE_ARGS} --verbose ${ZUS_VERBOSE} )
98
  endif()
99
  
100
  
101
  set(ZUSTRE_GENERATED_FILES "")
102
  file(MAKE_DIRECTORY ${ZUSTRE_OUTPUT_DIR})
103
  # create list of generated C files in parent scope
104
  if ("${E}" STREQUAL ".lus")
105
	set(ZUSTRE_GENERATED_FILES ${ZUSTRE_OUTPUT_DIR}/${L}.h   ${ZUSTRE_OUTPUT_DIR}/${L}.lusic )
106
	if(ZUS_OPTS MATCHES "smt2")
107
		set(ZUSTRE_GENERATED_FILES ${ZUSTRE_GENERATED_FILES} ${ZUSTRE_OUTPUT_DIR}/${L}.smt2)
108
	endif(ZUS_OPTS MATCHES "smt2")
109
  endif()
110
  file(COPY ${ZUS_LUS_FILE}   DESTINATION  ${ZUSTRE_OUTPUT_DIR})
111
  set(ZUSTRE_ARGS ${ZUSTRE_ARGS}  ${ZUSTRE_OUTPUT_DIR}/${L}.lus)
112
  
113

    
114
  set(ZUSTRE_ARGS_${L}_${ZUS_NODE}_${ZUS_OPTS_CUT} "${ZUSTRE_ARGS}" PARENT_SCOPE)
115
  set(ZUSTRE_GENERATED_FILES_${L}_${ZUS_NODE}_${ZUS_OPTS_CUT} "${ZUSTRE_GENERATED_FILES}" PARENT_SCOPE)
116
  set(ZUSTRE_OUTPUT_DIR_${L}_${ZUS_NODE}_${ZUS_OPTS_CUT} "${ZUSTRE_OUTPUT_DIR}" PARENT_SCOPE)
117
endfunction(Zustre_Compile)
118

    
119
# handle the QUIETLY and REQUIRED arguments and set ZUSTRE_FOUND to TRUE if
120
# all listed variables are TRUE
121
include(FindPackageHandleStandardArgs)
122
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZUSTRE
123
                                  REQUIRED_VARS ZUSTRE_COMPILER ZUSTRE_INCLUDE_DIR)
124
# VERSION FPHSA options not handled by CMake version < 2.8.2)
125
#                                  VERSION_VAR ZUSTRE_COMPILER_VERSION)
126
mark_as_advanced(ZUSTRE_INCLUDE_DIR)
127

    
128

    
(4-4/9)