]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
FindFASTJET
authoragrigora <alina.grigoras@cern.ch>
Tue, 28 Oct 2014 14:15:19 +0000 (15:15 +0100)
committeragrigora <alina.grigoras@cern.ch>
Mon, 15 Dec 2014 12:51:51 +0000 (13:51 +0100)
cmake/FindFASTJET.cmake
cmake/FindROOT.cmake

index beb56cf4de3ed147ce5c0a777e5b46cd361f2029..d3122d79eb1c7b546ff222c12f2dc86e3daf9272 100644 (file)
@@ -1,41 +1,75 @@
+# **************************************************************************
+# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
+# *                                                                        *
+# * Author: The ALICE Off-line Project.                                    *
+# * Contributors are mentioned in the code where appropriate.              *
+# *                                                                        *
+# * Permission to use, copy, modify and distribute this software and its   *
+# * documentation strictly for non-commercial purposes is hereby granted   *
+# * without fee, provided that the above copyright notice appears in all   *
+# * copies and that both the copyright notice and this permission notice   *
+# * appear in the supporting documentation. The authors make no claims     *
+# * about the suitability of this software for any purpose. It is          *
+# * provided "as is" without express or implied warranty.                  *
+# **************************************************************************
+
 # AliRoot Build System Module to find and configure FASTJET
-#
-# Author: Marco van Leeuwen
-#
-# Simple first version; checks env variables and fastjet-config; verifies that fastjet/PseudoJet.hh exists
-
-cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
-
-# FASTJET_ROOT is a legacy env variable; could be removed
-if (NOT FASTJET)
-  set(FASTJET $ENV{FASTJET_ROOT})
-endif(NOT FASTJET)
-
-if (NOT FASTJET)
-  set(FASTJET $ENV{FASTJET})
-endif(NOT FASTJET)
-
-if (NOT FASTJET)
-  execute_process (COMMAND fastjet-config --prefix OUTPUT_VARIABLE FASTJET)
-  string (STRIP "${FASTJET}" FASTJET)
-endif(NOT FASTJET)
-
-# Check for one of the header files
-if (FASTJET)
-  find_path(FASTJET include/fastjet/PseudoJet.hh PATHS ${FASTJET})
-  if (FASTJET-NOTFOUND)
-    message(STATUS "Header file fastjet/PseudoJet.hh not found in ${FASTJET}/include")
-  endif (FASTJET-NOTFOUND)
-endif (FASTJET)
-
-if (FASTJET AND NOT FASTJET-NOTFOUND) 
-  message(STATUS "FASTJET found in ${FASTJET}")
-  set (FASTJET_FOUND true)
-  set (FASTJET_INCLUDE_DIR ${FASTJET}/include)
-  message(STATUS "FASTJET include directory: ${FASTJET_INCLUDE_DIR}")
-  set (FASTJET_DEFINITIONS -DHAVE_FASTJET)
-else()
-  message(STATUS "FASTJET not found; make sure to set the FASTJET_ROOT environment variable or have fastjet-config in your path to use fastjet")
-  set (FASTJET)
-endif(FASTJET AND NOT FASTJET-NOTFOUND)
+# Author: Marco van Leeuwen 
+# FastJet installation is pointed during cmake configuration -DFASTJET
+# Variables set during Find:
+# - FASTJET_CONFIG - fastjet-config location
+# - FASTJET_VERSION
+# - FASTJET_VERSION_MAJOR
+# - FASTJET_VERSION_MINOR
+# - FASTJET_VERSION_PATCH
+# - FASTJET_INCLUDE_DIR - fastjet headers location
+# - FASTJET_DEFINITIONS - fastjet definition flags
+# - FASTJET_CXXFLAGS - fastjet compilation flags
+# - FASTJET_LIBS - fastjet libraries + linking flags
+
+set(FASTJET_FOUND FALSE)
+
+if(FASTJET)
+    # Check for fastjet-config script
+    find_program(FASTJET_CONFIG NAMES fastjet-config PATHS ${FASTJET}/bin NO_DEFAULT_PATH)
+    if(NOT FASTJET_CONFIG)
+        message(FATAL_ERROR "Could not find fastjet-config executable")
+    endif(NOT FASTJET_CONFIG)
+
+    # Check for header installation
+    find_path(FASTJETHH include/fastjet/PseudoJet.hh PATHS ${FASTJET})
+
+    if (FASTJETHH-NOTFOUND)
+        message(FATAL_ERROR "Header file fastjet/PseudoJet.hh not found in ${FASTJET}/include. Please check your FASTJET installation")
+    endif(FASTJETHH-NOTFOUND)
 
+    # FastJet version
+    execute_process(COMMAND ${FASTJET_CONFIG} --version OUTPUT_VARIABLE FASTJET_VERSION ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
+    if(error)
+        message(FATAL_ERROR "Error retrieving FastJet version : ${error}")
+    endif(error)
+
+    # Extract major, minor, and patch versions from
+    string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" FASTJET_VERSION_MAJOR "${FASTJET_VERSION}")
+    string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" FASTJET_VERSION_MINOR "${FASTJET_VERSION}")
+    string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" FASTJET_VERSION_PATCH "${FASTJET_VERSION}")
+
+    # Extracting compilation flags
+    execute_process(COMMAND ${FASTJET_CONFIG} --cxxflags OUTPUT_VARIABLE FASTJET_CXXFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
+    if(error)
+        message(FATAL_ERROR "Error retrieving FastJet compilation flags : ${error}")
+    endif(error)
+
+    # Extracting libraries and linking options
+    execute_process(COMMAND ${FASTJET_CONFIG} --libs OUTPUT_VARIABLE FASTJET_LIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
+    if(error)
+        message(FATAL_ERROR "Error retrieving FastJet libs : ${error}")
+    endif(error)
+
+    set(FASTJET_FOUND TRUE)
+    set(FASTJET_INCLUDE_DIR ${FASTJET}/include)
+    set(FASTJET_DEFINITIONS "-DHAVE_FASTJET")
+    message(STATUS "FastJet ${FASTJET_VERSION_MAJOR}.${FASTJET_VERSION_MINOR}.${FASTJET_VERSION_PATCH} installation found: ${FASTJET}")
+else()
+    message(STATUS "FastJet not found: disabling dependencies")
+endif(FASTJET)
index 0d057003044c9721d584bd0a51e1e51150b857bf..9d6b1e3db73a267eed5add24c021167905dfccd5 100644 (file)
@@ -33,6 +33,8 @@
 # - ROOT_HASXML - ROOT was built with XML support
 # - ROOT_FORTRAN - fortran compiler
 
+set(ROOT_FOUND FALSE)
+
 if(ROOTSYS)
     message(STATUS "Checking for a proper ROOT installation in ${ROOTSYS}.")
 
@@ -43,12 +45,10 @@ if(ROOTSYS)
     # Check for root-config scripts
     find_program(ROOT_CONFIG NAMES root-config PATHS ${ROOTSYS}/bin NO_DEFAULT_PATH)
 
-    if(ROOT_CONFIG)
-        message(STATUS "Found root-config: ${ROOT_CONFIG}")
-    else()
+    if(NOT ROOT_CONFIG)
         message(FATAL_ERROR "Could not find root-config script.")
-    endif(ROOT_CONFIG)
-
+    endif(NOT ROOT_CONFIG)
+        
     # Check for rlibmap
     find_program(ROOT_LIBMAP NAMES rlibmap PATHS ${ROOTSYS}/bin NO_DEFAULT_PATH)
     if(ROOT_LIBMAP)