cmake: generating AliRoot-config.cmake to be used by externals
authoragrigora <alina.grigoras@cern.ch>
Thu, 15 Jan 2015 16:42:35 +0000 (17:42 +0100)
committeragrigora <alina.grigoras@cern.ch>
Thu, 15 Jan 2015 16:47:06 +0000 (17:47 +0100)
Generating AliRoot-config.cmake to be used by AliPhysics
 - AliRoot version major minor and patch as reported by closest
   tag to the current hash
 - ROOT version
 - Arch and compiler

CMakeLists.txt
cmake/AliRoot-config.cmake.in [new file with mode: 0644]
cmake/CheckGitVersion.cmake

index 8a44a28..80a420f 100644 (file)
@@ -203,6 +203,10 @@ find_package(FASTJET)
 # ZEROMQ
 find_package(ZeroMQ)
 
+# Generating the AliRoot-config.cmake file
+configure_file(${PROJECT_SOURCE_DIR}/cmake/AliRoot-config.cmake.in ${CMAKE_BINARY_DIR}/version/AliRoot-config.cmake @ONLY)
+install(FILES ${PROJECT_BINARY_DIR}/cmake/AliRoot-config.cmake DESTINATION etc)
+
 # General flags -> Should be moved into a configuration file
 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
 set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
diff --git a/cmake/AliRoot-config.cmake.in b/cmake/AliRoot-config.cmake.in
new file mode 100644 (file)
index 0000000..8999074
--- /dev/null
@@ -0,0 +1,38 @@
+############################################################################
+# AliRoot cmake configuration file                                         #
+############################################################################
+
+############################################################################
+# AliRoot version and configuration                                        #
+############################################################################
+# Version
+set(AliRoot_VERSION @ALIROOT_VERSION@)
+set(AliRoot_VERSION_MAJOR @ALIROOT_VERSION_MAJOR@)
+set(AliRoot_VERSION_MINOR @ALIROOT_VERSION_MINOR@)
+set(AliRoot_VERSION_PATCH @ALIROOT_VERSION_PATCH@)
+
+# Git revision
+set(AliRoot_REVISION @GIT_SHORT_SHA1@)
+
+# Information about architecture and compiler
+set(AliRoot_ARCH @CMAKE_SYSTEM@)
+set(AliRoot_COMPILER @CMAKE_CXX_COMPILER_ID@)
+set(AliRoot_COMPILER_VERSION @CMAKE_CXX_COMPILER_VERSION@)
+
+############################################################################
+# FastJet version                                                          #
+############################################################################
+set(FASTJET_VERSION @FASTJET_VERSION@)
+set(FASTJET_VERSION_MAJOR @FASTJET_VERSION_MAJOR@)
+set(FASTJET_VERSION_MINOR @FASTJET_VERSION_MINOR@)
+set(FASTJET_VERSION_PATCH @FASTJET_VERSION_PATCH@)
+
+############################################################################
+# ROOT version                                                             #
+############################################################################
+set(ROOT_VERSION @ROOT_VERSION@) # as reported by root-config
+set(ROOT_VERSION_MAJOR @ROOT_VERSION_MAJOR@)
+set(ROOT_VERSIOM_MINOR @ROOT_VERSION_MINOR@)
+set(ROOT_VERSION_PATCH @ROOT_VERSION_PATCH@)
+
+
index 814d81c..531673a 100644 (file)
@@ -80,6 +80,14 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
             string(REPLACE "tags/" ""  ALIROOT_GIT_TAG ${ALIROOT_GIT_TAG})
         endif(ALIROOT_GIT_TAG)
         
+        # using the closest tag for branches
+        git_describe(ALIROOT_CLOSEST_GIT_TAG "--abbrev=0")
+
+        if(ALIROOT_GIT_TAG)
+            string(STRIP ${ALIROOT_GIT_TAG} ALIROOT_GIT_TAG)
+            string(REPLACE "tags/" ""  ALIROOT_GIT_TAG ${ALIROOT_GIT_TAG})
+        endif(ALIROOT_GIT_TAG)
+        
         STRING(REGEX REPLACE "^(.+/)(.+)/(.*)$" "\\2" BRANCH_TYPE "${GIT_REFSPEC}" )
         
         # the revision is not set in the case of a branch, it means we are doing development
@@ -87,6 +95,7 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
         if(BRANCH_TYPE STREQUAL "heads")
             set(ALIROOT_REVISION "ThisIsaBranchNoRevisionProvided")
             set(ALIROOT_SERIAL 0)
+            set(ALIROOT_GIT_TAG ${ALIROOT_CLOSEST_GIT_TAG})
             STRING(REGEX REPLACE "^(.+/)(.+/)(.*)$" "\\3" SHORT_BRANCH "${GIT_REFSPEC}" )
             message(STATUS "This is a working branch, ARVersion will not contain the revision and the serial number")
         else()
@@ -98,10 +107,15 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
         set(ALIROOT_BRANCH ${SHORT_BRANCH})
         set(ALIROOT_VERSION ${SHORT_BRANCH})
         
+        # extract major minor and patch from AliRoot tag
+        string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" ALIROOT_VERSION_MAJOR "${ALIROOT_GIT_TAG}")
+        string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" ALIROOT_VERSION_MINOR "${ALIROOT_GIT_TAG}")
+        string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" ALIROOT_VERSION_PATCH "${ALIROOT_GIT_TAG}")
+        message(STATUS "Found ALIROOT version ${ALIROOT_VERSION_MAJOR}.${ALIROOT_VERSION_MINOR}.${ALIROOT_VERSION_PATCH}")
+        
         # Replace - with . for rpm creation
         string(REPLACE "-" "." ALIROOT_VERSION_RPM ${ALIROOT_VERSION})
 
-
         message(STATUS "Aliroot branch/tag: \"${ALIROOT_VERSION}\" - Revision:  \"${GIT_SHORT_SHA1}\" - Serial: \"${ALIROOT_SERIAL_ORIGINAL}\"")
 
     else()