Project

General

Profile

Revision 86ae18b7 share/FindLustre.cmake

View differences:

share/FindLustre.cmake
17 17
#                  LUS_FILES <Lustre files>
18 18
#                  [USER_C_FILES <C files>]
19 19
#                  [VERBOSE <level>]
20
#                  [LUSI]
21 20
#                  LIBNAME <libraryName>)
22 21
#
23 22
# When used the Lustre_Compile macro define the variable
......
73 72
# Macros used to compile a lustre library
74 73
include(CMakeParseArguments)
75 74
function(Lustre_Compile)
76
  set(options LUSI)
75
  set(options "")
77 76
  set(oneValueArgs NODE LIBNAME VERBOSE)
78 77
  set(multiValueArgs LUS_FILES USER_C_FILES)
79 78
  cmake_parse_arguments(LUS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
80 79

  
81
  if(LUS_LUSI)
82
    set(LUSTRE_LUSI_OPT "-lusi")
83
  endif()
84

  
85 80
  if (NOT LUS_LIBNAME)
86 81
    message(FATAL_ERROR "You should specify LIBNAME for each Lustre_Compile call.")
87 82
  endif()
88 83

  
89 84
  if(LUS_NODE)
90
    set(LUSTRE_NODE_OPT "-node;${LUS_NODE}")
85
    set(LUSTRE_NODE_OPT "-node ${LUS_NODE}")
91 86
    set(LUSTRE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/lus_${LUS_LIBNAME}/${LUS_NODE}")
92 87
  else()
93 88
    set(LUSTRE_NODE_OPT "")
......
95 90
  endif()
96 91

  
97 92
  if (LUS_VERBOSE)
98
    set(LUSTRE_VERBOSE_OPT "-verbose;${LUS_VERBOSE}")
93
    set(LUSTRE_VERBOSE_OPT "-verbose ${LUS_VERBOSE}")
99 94
  else()
100 95
    # the default is to be quiet.
101 96
    set(LUSTRE_VERBOSE_OPT "-verbose;0")
......
110 105
    get_filename_component(E ${LFILE} EXT)
111 106
    if ("${E}" STREQUAL ".lus")
112 107
      set(LUSTRE_GENERATED_FILES ${LUSTRE_OUTPUT_DIR}/${L}.h ${LUSTRE_OUTPUT_DIR}/${L}.c ${LUSTRE_OUTPUT_DIR}/${L}_alloc.h)
113
      if(LUS_NODE)
114
         list(APPEND LUSTRE_GENERATED_FILES ${LUSTRE_OUTPUT_DIR}/${L}_main.c)
115
         list(APPEND LUSTRE_GENERATED_FILES ${LUSTRE_INCLUDE_DIR}/io_frontend.c)
116
      endif()
117 108
    elseif("${E}" STREQUAL ".lusi")
118 109
      set(LUSTRE_GENERATED_FILES ${LUSTRE_OUTPUT_DIR}/${L}.h)
119 110
    endif()
120 111
    list(APPEND GLOBAL_LUSTRE_GENERATED_C_FILES ${LUSTRE_GENERATED_FILES})
121 112
    set(LUSTRE_GENERATED_FILES ${LUSTRE_GENERATED_FILES} ${LUSTRE_OUTPUT_DIR}/${L}.lusic)
122
    if (LUS_LUSI)
123
      add_custom_command(
124
         OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${LFILE}i
125
         COMMAND ${LUSTRE_COMPILER} ${LUSTRE_LUSI_OPT} ${LFILE}
126
         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${LFILE}
127
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
128
         COMMENT "Compile Lustre source(s): ${LFILE} with option -lusi."
129
         )
130
      message(STATUS "lustrec will produce lusi file: ${LFILE}i")
131
    endif()
132 113
    add_custom_command(
133 114
      OUTPUT ${LUSTRE_GENERATED_FILES}
134 115
      COMMAND ${LUSTRE_COMPILER} ${LUSTRE_VERBOSE_OPT} ${LUSTRE_NODE_OPT} -d ${LUSTRE_OUTPUT_DIR} ${LFILE}
......
140 121
  endforeach()
141 122

  
142 123
  include_directories(${LUSTRE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${LUSTRE_OUTPUT_DIR})
143
  if(LUS_NODE)
144
  add_executable(${LUS_LIBNAME}
145
              ${GLOBAL_LUSTRE_GENERATED_C_FILES} ${LUS_USER_C_FILES}
146
              )
147
  else()
148 124
  add_library(${LUS_LIBNAME} SHARED
149 125
              ${GLOBAL_LUSTRE_GENERATED_C_FILES} ${LUS_USER_C_FILES}
150 126
              )
151
  endif()
152 127
  set_target_properties(${LUS_LIBNAME} PROPERTIES COMPILE_FLAGS "-std=c99")
153 128
  set(LUSTRE_GENERATED_C_FILES_${LUS_LIBNAME} "${GLOBAL_LUSTRE_GENERATED_C_FILES}" PARENT_SCOPE)
154 129
  message(STATUS "Lustre: Added rule for building lustre library: ${LUS_LIBNAME}")

Also available in: Unified diff