From 719f4b27973b493c867473b29c3f70f093140da1 Mon Sep 17 00:00:00 2001
From: enoulard <enoulard@041b043f-8d7c-46b2-b46e-ef0dd855326e>
Date: Thu, 13 Aug 2015 13:52:14 +0000
Subject: [PATCH] Update FindLustre in order to handle a default VERBOSE option
 set to 0 and the proper c99 compiler option

---
 share/FindLustre.cmake | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/share/FindLustre.cmake b/share/FindLustre.cmake
index ee9a6098..bb0cfb4f 100644
--- a/share/FindLustre.cmake
+++ b/share/FindLustre.cmake
@@ -15,7 +15,15 @@
 # The module defines some functions:
 #   Lustre_Compile([NODE <Lustre Main Node>]
 #                  LUS_FILES <Lustre files>
-#                  [USER_C_FILES <C files>])
+#                  [USER_C_FILES <C files>]
+#                  [VERBOSE <level>]
+#                  LIBNAME <libraryName>)
+#
+# When used the Lustre_Compile macro define the variable
+# LUSTRE_GENERATED_C_FILES_<libraryName> in the parent scope
+# so that the caller can get (if needed) the list of Lustre generated files.
+# The VERBOSE level is a numeric value passed directly to the -verbose
+# command line option of the lustre compiler
 #
 
 if(LUSTRE_PATH_HINT)
@@ -65,7 +73,7 @@ find_path(LUSTRE_INCLUDE_DIR
 include(CMakeParseArguments)
 function(Lustre_Compile)
   set(options "")
-  set(oneValueArgs NODE LIBNAME)
+  set(oneValueArgs NODE LIBNAME VERBOSE)
   set(multiValueArgs LUS_FILES USER_C_FILES)
   cmake_parse_arguments(LUS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
@@ -81,6 +89,13 @@ function(Lustre_Compile)
     set(LUSTRE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/lus_${LUS_LIBNAME}")
   endif()
 
+  if (LUS_VERBOSE)
+    set(LUSTRE_VERBOSE_OPT "-verbose ${LUS_VERBOSE}")
+  else()
+    # the default is to be quiet.
+    set(LUSTRE_VERBOSE_OPT "-verbose;0")
+  endif()
+
   file(MAKE_DIRECTORY ${LUSTRE_OUTPUT_DIR})
   set(GLOBAL_LUSTRE_GENERATED_C_FILES "")
   # create list of generated C files in parent scope
@@ -97,7 +112,7 @@ function(Lustre_Compile)
     set(LUSTRE_GENERATED_FILES ${LUSTRE_GENERATED_FILES} ${LUSTRE_OUTPUT_DIR}/${L}.lusic)
     add_custom_command(
       OUTPUT ${LUSTRE_GENERATED_FILES}
-      COMMAND ${LUSTRE_COMPILER} ${LUSTRE_NODE_OPT} -d ${LUSTRE_OUTPUT_DIR} ${LFILE}
+      COMMAND ${LUSTRE_COMPILER} ${LUSTRE_VERBOSE_OPT} ${LUSTRE_NODE_OPT} -d ${LUSTRE_OUTPUT_DIR} ${LFILE}
       DEPENDS ${LFILE}
       WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
       COMMENT "Compile Lustre source(s): ${LFILE} (generates: ${LUSTRE_GENERATED_FILES})."
@@ -109,6 +124,7 @@ function(Lustre_Compile)
   add_library(${LUS_LIBNAME} SHARED
               ${GLOBAL_LUSTRE_GENERATED_C_FILES} ${LUS_USER_C_FILES}
               )
+  set_target_properties(${LUS_LIBNAME} PROPERTIES COMPILE_FLAGS "-std=c99")
   set(LUSTRE_GENERATED_C_FILES_${LUS_LIBNAME} "${GLOBAL_LUSTRE_GENERATED_C_FILES}" PARENT_SCOPE)
   message(STATUS "Lustre: Added rule for building lustre library: ${LUS_LIBNAME}")
 endfunction(Lustre_Compile)
-- 
GitLab