From ecba379587e1295a5fffcd08e69f43d1b915774d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Boniol?= <frederic.boniol@onera.fr>
Date: Tue, 20 Dec 2016 16:18:47 +0100
Subject: [PATCH] add lusi option

---
 share/FindLustre.cmake | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/share/FindLustre.cmake b/share/FindLustre.cmake
index bb0cfb4f..235f5595 100644
--- a/share/FindLustre.cmake
+++ b/share/FindLustre.cmake
@@ -17,6 +17,7 @@
 #                  LUS_FILES <Lustre files>
 #                  [USER_C_FILES <C files>]
 #                  [VERBOSE <level>]
+#		   [LUSI]
 #                  LIBNAME <libraryName>)
 #
 # When used the Lustre_Compile macro define the variable
@@ -72,11 +73,15 @@ find_path(LUSTRE_INCLUDE_DIR
 # Macros used to compile a lustre library
 include(CMakeParseArguments)
 function(Lustre_Compile)
-  set(options "")
+  set(options LUSI)
   set(oneValueArgs NODE LIBNAME VERBOSE)
   set(multiValueArgs LUS_FILES USER_C_FILES)
   cmake_parse_arguments(LUS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
+  if(LUS_LUSI)
+    set(LUSTRE_LUSI_OPT "-lusi")
+  endif()    
+
   if (NOT LUS_LIBNAME)
     message(FATAL_ERROR "You should specify LIBNAME for each Lustre_Compile call.")
   endif()
@@ -110,6 +115,18 @@ function(Lustre_Compile)
     endif()
     list(APPEND GLOBAL_LUSTRE_GENERATED_C_FILES ${LUSTRE_GENERATED_FILES})
     set(LUSTRE_GENERATED_FILES ${LUSTRE_GENERATED_FILES} ${LUSTRE_OUTPUT_DIR}/${L}.lusic)
+    if (LUS_LUSI)
+      add_custom_command(
+         OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${LFILE}i
+         #OUTPUT ${LUSTRE_OUTPUT_DIR}/${L}.lusi
+      	 COMMAND ${LUSTRE_COMPILER} ${LUSTRE_LUSI_OPT} ${LFILE}
+	 #COMMAND ${CMAKE_COMMAND} -E rename ${L}.lusi ${LUSTRE_OUTPUT_DIR}/${L}.lusi
+         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${LFILE}
+         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+         COMMENT "Compile Lustre source(s): ${LFILE} with option -lusi."
+         )
+      message(STATUS "lustrec will produce lusi file: ${LFILE}i")
+    endif()
     add_custom_command(
       OUTPUT ${LUSTRE_GENERATED_FILES}
       COMMAND ${LUSTRE_COMPILER} ${LUSTRE_VERBOSE_OPT} ${LUSTRE_NODE_OPT} -d ${LUSTRE_OUTPUT_DIR} ${LFILE}
-- 
GitLab