From c84374ab33ac9811a017af6a5639ad8d49728dff Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Mon, 22 Jun 2015 14:11:30 +0000
Subject: [PATCH] sources inherits version numbers from the main CMakeLists.txt
 file

---
 CMakeLists.txt                  |  6 +++++-
 example/lapack_to_morse/step0.h |  9 +--------
 include/CMakeLists.txt          |  6 +++++-
 include/{morse.h => morse.h.in} | 12 ++++++------
 4 files changed, 17 insertions(+), 16 deletions(-)
 rename include/{morse.h => morse.h.in} (91%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7fe179392..d1950ec0e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,9 +37,13 @@ if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
 endif()
 
 # set project version number
+set(MORSE_VERSION_MAJOR 1)
+set(MORSE_VERSION_MINOR 0)
+set(MORSE_VERSION_MICRO 0)
+# set subproject version number
 set(CHAMELEON_VERSION_MAJOR 0)
 set(CHAMELEON_VERSION_MINOR 9)
-set(CHAMELEON_VERSION_PATCH 1)
+set(CHAMELEON_VERSION_MICRO 1)
 
 set( MORSE_DISTRIB_DIR "" CACHE PATH "Directory of MORSE distribution")
 
diff --git a/example/lapack_to_morse/step0.h b/example/lapack_to_morse/step0.h
index 5c9630d1b..f5b776c33 100644
--- a/example/lapack_to_morse/step0.h
+++ b/example/lapack_to_morse/step0.h
@@ -35,10 +35,6 @@
 #include <coreblas/include/cblas.h>
 #include <coreblas/include/lapacke.h>
 
-#define CHAMELEON_VERSION_MAJOR 0
-#define CHAMELEON_VERSION_MINOR 9
-#define CHAMELEON_VERSION_MICRO 0
-
 /* Integer parameters for step0 */
 enum iparam_step0 {
     IPARAM_THRDNBR,        /* Number of cores                            */
@@ -112,15 +108,12 @@ static void print_header(char *prog_name, int * iparam) {
 #endif
 
     printf( "#\n"
-            "# CHAMELEON %d.%d.%d, %s\n"
+            "# CHAMELEON %s\n"
             "# Nb threads: %d\n"
             "# N:          %d\n"
             "# IB:         %d\n"
             "# eps:        %e\n"
             "#\n",
-            CHAMELEON_VERSION_MAJOR,
-            CHAMELEON_VERSION_MINOR,
-            CHAMELEON_VERSION_MICRO,
             prog_name,
             iparam[IPARAM_THRDNBR],
             iparam[IPARAM_N],
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 061af84be..c35f8aa80 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -40,6 +40,10 @@ set(ZHDR
 precisions_rules_py(CHAMELEON_HDRS_GENERATED "${ZHDR}"
                     PRECISIONS "z;c;d;s;zc;ds")
 
+configure_file("morse.h.in"
+               "morse.h"
+               @ONLY)
+
 # Define the list of headers
 # --------------------------
 set(CHAMELEON_HDRS
@@ -70,12 +74,12 @@ set(HDR_INSTALL
     morse_simulate.h
     morse_struct.h
     morse_types.h
-    morse.h
     runtime.h
     )
 foreach( hdr_file ${CHAMELEON_HDRS_GENERATED} )
     list(APPEND HDR_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/${hdr_file})
 endforeach()
+list(APPEND HDR_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/morse.h)
 
 # installation
 # ------------
diff --git a/include/morse.h b/include/morse.h.in
similarity index 91%
rename from include/morse.h
rename to include/morse.h.in
index 9f34a8eeb..d3297c93f 100644
--- a/include/morse.h
+++ b/include/morse.h.in
@@ -27,13 +27,13 @@
 #ifndef _MORSE_H_
 #define _MORSE_H_
 
-#define MORSE_VERSION_MAJOR 1
-#define MORSE_VERSION_MINOR 0
-#define MORSE_VERSION_MICRO 0
+#define MORSE_VERSION_MAJOR @MORSE_VERSION_MAJOR@
+#define MORSE_VERSION_MINOR @MORSE_VERSION_MINOR@
+#define MORSE_VERSION_MICRO @MORSE_VERSION_MICRO@
 
-#define CHAMELEON_VERSION_MAJOR 0
-#define CHAMELEON_VERSION_MINOR 9
-#define CHAMELEON_VERSION_MICRO 0
+#define CHAMELEON_VERSION_MAJOR @CHAMELEON_VERSION_MAJOR@
+#define CHAMELEON_VERSION_MINOR @CHAMELEON_VERSION_MINOR@
+#define CHAMELEON_VERSION_MICRO @CHAMELEON_VERSION_MICRO@
 
 
 /* ****************************************************************************
-- 
GitLab