From 8279ef5ea9ccfd0f658bfdda8aa232521ab79c36 Mon Sep 17 00:00:00 2001
From: Steven Murray <steven.murray@cern.ch>
Date: Fri, 18 Oct 2013 11:07:34 +0200
Subject: [PATCH] Moved the generation of compilation variables from the
 cmake/CASTORVersion.cmake module file to the top-level CMakeList.txt file.  I
 believe the cmake/CASTORVersion.cmake module should just concentrate on the
 single responsibility of determining the CASTOR version.

---
 CMakeLists.txt            | 13 +++++++
 cmake/CASTORVersion.cmake | 80 +++++++++++++++++----------------------
 2 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 508df6aa95..7eafa82da5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,19 @@ set (CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
 
 set_property ( DIRECTORY PROPERTY COMPILE_DEFINITIONS _LARGEFILE64_SOURCE)
 
+# Generate the compilation variables, if needed
+if(NOT DEFINED COMPILING_NOSTK)
+  set(COMPILING_NOSTK 0)
+  message(STATUS "Setting option COMPILING_NOSTK to default (0). Override with
+option -DCOMPILING_NOSTK:STRING=1")
+endif(NOT DEFINED COMPILING_NOSTK)
+
+if(NOT DEFINED COMPILING_CLIENT)
+  set(COMPILING_CLIENT 0)
+  message(STATUS "Setting option COMPILING_CLIENT to default (0). Override
+with option -DCOMPILING_CLIENT:STRING=1")
+endif(NOT DEFINED COMPILING_CLIENT)
+
 ################################################################################
 # Include the subdirectories of the project
 ################################################################################
diff --git a/cmake/CASTORVersion.cmake b/cmake/CASTORVersion.cmake
index e51f770a29..b0000d4f66 100644
--- a/cmake/CASTORVersion.cmake
+++ b/cmake/CASTORVersion.cmake
@@ -9,60 +9,50 @@
 #  "cmake -DVCS_VERSION:STRING=git-6789abc")
 
 # Extract the versions from changelog anyway
-SET(VERSION_RE "^castor \\(([0-9]+)\\.([0-9]+)\\.([0-9]+)-([0-9]+)\\).*")
-FILE(STRINGS debian/changelog CHANGELOG_HEAD
+set(VERSION_RE "^castor \\(([0-9]+)\\.([0-9]+)\\.([0-9]+)-([0-9]+)\\).*")
+file(STRINGS debian/changelog CHANGELOG_HEAD
      REGEX ${VERSION_RE}
      LIMIT_COUNT 1)
-# MESSAGE("Changelog line: ${CHANGELOG_HEAD}")
-# MESSAGE("VERSION_RE ${VERSION_RE}")
-STRING(REGEX REPLACE "${VERSION_RE}" "\\1" A ${CHANGELOG_HEAD})
-STRING(REGEX REPLACE "${VERSION_RE}" "\\2" B ${CHANGELOG_HEAD})
-STRING(REGEX REPLACE "${VERSION_RE}" "\\3" C ${CHANGELOG_HEAD})
-STRING(REGEX REPLACE "${VERSION_RE}" "\\4" D ${CHANGELOG_HEAD})
-# MESSAGE("A ${A} B ${B} C ${C} D ${D}")
+# message("Changelog line: ${CHANGELOG_HEAD}")
+# message("VERSION_RE ${VERSION_RE}")
+string(REGEX REPLACE "${VERSION_RE}" "\\1" A ${CHANGELOG_HEAD})
+string(REGEX REPLACE "${VERSION_RE}" "\\2" B ${CHANGELOG_HEAD})
+string(REGEX REPLACE "${VERSION_RE}" "\\3" C ${CHANGELOG_HEAD})
+string(REGEX REPLACE "${VERSION_RE}" "\\4" D ${CHANGELOG_HEAD})
+# message("A ${A} B ${B} C ${C} D ${D}")
 
 # Get versions from environment, if availble
 # MAJOR
-IF(NOT $ENV{MAJOR_CASTOR_VERSION} STREQUAL "")
-  SET(MAJOR_CASTOR_VERSION $ENV{MAJOR_CASTOR_VERSION})
-  MESSAGE(STATUS "Got MAJOR_CASTOR_VERSION from environment: ${MAJOR_CASTOR_VERSION}")
-ELSE(NOT $ENV{MAJOR_CASTOR_VERSION} STREQUAL "")
-  SET(MAJOR_CASTOR_VERSION "${A}.${B}")
-  MESSAGE(STATUS "Got MAJOR_CASTOR_VERSION from debian/changelog: ${MAJOR_CASTOR_VERSION}")
-ENDIF(NOT $ENV{MAJOR_CASTOR_VERSION} STREQUAL "")
+if(NOT $ENV{MAJOR_CASTOR_VERSION} STREQUAL "")
+  set(MAJOR_CASTOR_VERSION $ENV{MAJOR_CASTOR_VERSION})
+  message(STATUS "Got MAJOR_CASTOR_VERSION from environment: ${MAJOR_CASTOR_VERSION}")
+else(NOT $ENV{MAJOR_CASTOR_VERSION} STREQUAL "")
+  set(MAJOR_CASTOR_VERSION "${A}.${B}")
+  message(STATUS "Got MAJOR_CASTOR_VERSION from debian/changelog: ${MAJOR_CASTOR_VERSION}")
+endif(NOT $ENV{MAJOR_CASTOR_VERSION} STREQUAL "")
 
 # MINOR
-IF(NOT $ENV{MINOR_CASTOR_VERSION} STREQUAL "")
-  SET(MINOR_CASTOR_VERSION $ENV{MINOR_CASTOR_VERSION})
-  MESSAGE(STATUS "Got MINOR_CASTOR_VERSION from environment: ${MINOR_CASTOR_VERSION}")
-ELSE(NOT $ENV{MINOR_CASTOR_VERSION} STREQUAL "")
-  SET(MINOR_CASTOR_VERSION "${C}.${D}")
-  MESSAGE(STATUS "Got MINOR_CASTOR_VERSION from debian/changelog: ${MINOR_CASTOR_VERSION}")
-ENDIF(NOT $ENV{MINOR_CASTOR_VERSION} STREQUAL "")
+if(NOT $ENV{MINOR_CASTOR_VERSION} STREQUAL "")
+  set(MINOR_CASTOR_VERSION $ENV{MINOR_CASTOR_VERSION})
+  message(STATUS "Got MINOR_CASTOR_VERSION from environment: ${MINOR_CASTOR_VERSION}")
+else(NOT $ENV{MINOR_CASTOR_VERSION} STREQUAL "")
+  set(MINOR_CASTOR_VERSION "${C}.${D}")
+  message(STATUS "Got MINOR_CASTOR_VERSION from debian/changelog: ${MINOR_CASTOR_VERSION}")
+endif(NOT $ENV{MINOR_CASTOR_VERSION} STREQUAL "")
 
 # Change the release number if VCS version is provided
-IF(DEFINED VCS_VERSION)
+if(DEFINED VCS_VERSION)
   STRING(REGEX REPLACE "\\..*" ".${VCS_VERSION}" MINOR_CASTOR_VERSION ${MINOR_CASTOR_VERSION})
-  MESSAGE(STATUS "Replaced VCS_VERSION in MINOR_CASTOR_VERSION: ${MINOR_CASTOR_VERSION}")
-ENDIF(DEFINED VCS_VERSION)
+  message(STATUS "Replaced VCS_VERSION in MINOR_CASTOR_VERSION: ${MINOR_CASTOR_VERSION}")
+endif(DEFINED VCS_VERSION)
 
 # Generate derived version from result. Almost all combinaisons are needed at some point!
-STRING(REGEX REPLACE "(.*)\\..*" "${MAJOR_CASTOR_VERSION}.\\1" CASTOR_VERSION ${MINOR_CASTOR_VERSION})
-STRING(REGEX REPLACE ".*\\." "" CASTOR_RELEASE ${MINOR_CASTOR_VERSION})
-STRING(REGEX REPLACE "\\..*" "" MAJOR_CASTOR_VERSION_TOP ${MAJOR_CASTOR_VERSION})
-STRING(REGEX REPLACE ".*\\." "" MAJOR_CASTOR_VERSION_BOTTOM ${MAJOR_CASTOR_VERSION})
-STRING(REGEX REPLACE "\\..*" "" MINOR_CASTOR_VERSION_TOP ${MINOR_CASTOR_VERSION})
-STRING(REGEX REPLACE ".*\\." "" MINOR_CASTOR_VERSION_BOTTOM ${MINOR_CASTOR_VERSION})
-MESSAGE(STATUS "Generated derived versions: CASTOR_VERSION: ${CASTOR_VERSION} CASTOR_RELEASE: ${CASTOR_RELEASE}")
-MESSAGE(STATUS "MAJOR_CASTOR_VERSION_TOP=${MAJOR_CASTOR_VERSION_TOP} MAJOR_CASTOR_VERSION_BOTTOM=${MAJOR_CASTOR_VERSION_BOTTOM}")
-MESSAGE(STATUS "MINOR_CASTOR_VERSION_TOP=${MINOR_CASTOR_VERSION_TOP} MINOR_CASTOR_VERSION_BOTTOM=${MINOR_CASTOR_VERSION_BOTTOM}")
-
-# Generate the compilation variables, if needed
-IF(NOT DEFINED COMPILING_NOSTK)
-  SET(COMPILING_NOSTK 0)
-  MESSAGE(STATUS "Setting option COMPILING_NOSTK to default (0). Override with option -DCOMPILING_NOSTK:STRING=1")
-ENDIF(NOT DEFINED COMPILING_NOSTK)
-IF(NOT DEFINED COMPILING_CLIENT)
-  SET(COMPILING_CLIENT 0)
-  MESSAGE(STATUS "Setting option COMPILING_CLIENT to default (0). Override with option -DCOMPILING_CLIENT:STRING=1")
-ENDIF(NOT DEFINED COMPILING_CLIENT)
+string(REGEX REPLACE "(.*)\\..*" "${MAJOR_CASTOR_VERSION}.\\1" CASTOR_VERSION ${MINOR_CASTOR_VERSION})
+string(REGEX REPLACE ".*\\." "" CASTOR_RELEASE ${MINOR_CASTOR_VERSION})
+string(REGEX REPLACE "\\..*" "" MAJOR_CASTOR_VERSION_TOP ${MAJOR_CASTOR_VERSION})
+string(REGEX REPLACE ".*\\." "" MAJOR_CASTOR_VERSION_BOTTOM ${MAJOR_CASTOR_VERSION})
+string(REGEX REPLACE "\\..*" "" MINOR_CASTOR_VERSION_TOP ${MINOR_CASTOR_VERSION})
+string(REGEX REPLACE ".*\\." "" MINOR_CASTOR_VERSION_BOTTOM ${MINOR_CASTOR_VERSION})
+message(STATUS "Generated derived versions: CASTOR_VERSION: ${CASTOR_VERSION} CASTOR_RELEASE: ${CASTOR_RELEASE}")
+message(STATUS "MAJOR_CASTOR_VERSION_TOP=${MAJOR_CASTOR_VERSION_TOP} MAJOR_CASTOR_VERSION_BOTTOM=${MAJOR_CASTOR_VERSION_BOTTOM}")
+message(STATUS "MINOR_CASTOR_VERSION_TOP=${MINOR_CASTOR_VERSION_TOP} MINOR_CASTOR_VERSION_BOTTOM=${MINOR_CASTOR_VERSION_BOTTOM}")
-- 
GitLab