Back to home page

sPhenix code displayed by LXR

 
 

    


Warning, /GenFit/cmake/FindROOT.cmake is written in an unsupported language. File is not indexed.

0001 ###############################################################################
0002 # cmake module for finding ROOT
0003 #
0004 # requires:
0005 #   MacroCheckPackageLibs.cmake for checking package libraries
0006 #
0007 # Following cmake variables are returned by this module:
0008 #
0009 #   ROOT_FOUND              : set to TRUE if ROOT found
0010 #       If FIND_PACKAGE is called with REQUIRED and COMPONENTS arguments
0011 #       ROOT_FOUND is only set to TRUE if ALL components are found.
0012 #       If REQUIRED is NOT set components may or may not be available
0013 #
0014 #   ROOT_LIBRARIES          : list of ROOT libraries (NOT including COMPONENTS)
0015 #   ROOT_INCLUDE_DIRS       : list of paths to be used with INCLUDE_DIRECTORIES
0016 #   ROOT_LIBRARY_DIRS       : list of paths to be used with LINK_DIRECTORIES
0017 #   ROOT_COMPONENT_LIBRARIES    : list of ROOT component libraries
0018 #   ROOT_${COMPONENT}_FOUND     : set to TRUE or FALSE for each library
0019 #   ROOT_${COMPONENT}_LIBRARY   : path to individual libraries
0020 #   ROOT_LIBS                : required ROOT libraries
0021 #   ROOT_found_version      : contains the version of ROOT in a comparable
0022 #                             way, i.e. 5.99.00 as 59900
0023 #   ROOT_CXX_FLAGS          : the c++ compiler flags
0024 #
0025 #   Please note that by convention components should be entered exactly as
0026 #   the library names, i.e. the component name equivalent to the library
0027 #   $ROOTSYS/lib/libMathMore.so should be called MathMore and NOT:
0028 #       mathmore or Mathmore or MATHMORE
0029 #
0030 #   However to follow the usual cmake convention it is agreed that the
0031 #   ROOT_${COMPONENT}_FOUND and ROOT_${COMPONENT}_LIBRARY variables are ALL
0032 #   uppercase, i.e. the MathMore component returns: ROOT_MATHMORE_FOUND and
0033 #   ROOT_MATHMORE_LIBRARY NOT ROOT_MathMore_FOUND or ROOT_MathMore_LIBRARY
0034 #
0035 #
0036 # The additional ROOT components should be defined as follows:
0037 # FIND_PACKAGE( ROOT COMPONENTS MathMore Gdml Geom ...)
0038 #
0039 # If components are required use:
0040 # FIND_PACKAGE( ROOT REQUIRED COMPONENTS MathMore Gdml Geom ...)
0041 #
0042 # If only root is required and components are NOT required use:
0043 # FIND_PACKAGE( ROOT REQUIRED )
0044 # FIND_PACKAGE( ROOT COMPONENTS MathMore Gdml Geom ... QUIET )
0045 #   then you need to check for ROOT_MATHMORE_FOUND, ROOT_GDML_FOUND, etc.
0046 #
0047 # The variable ROOT_USE_COMPONENTS can also be used before calling
0048 # FIND_PACKAGE, i.e.:
0049 # SET( ROOT_USE_COMPONENTS MathMore Gdml Geom )
0050 # FIND_PACKAGE( ROOT REQUIRED ) # all ROOT_USE_COMPONENTS must also be found
0051 # FIND_PACKAGE( ROOT ) # check for ROOT_FOUND, ROOT_MATHMORE_FOUND, etc.
0052 #
0053 # original @author Jan Engels, DESY
0054 # mucked about and slightly abused by Christoph Rosemann, DESY *still needs some cleaning up, though*
0055 ###############################################################################
0056 
0057 # ==============================================
0058 # ===        ROOT_CONFIG_EXECUTABLE          ===
0059 # ==============================================
0060 
0061 SET( ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND )
0062 MARK_AS_ADVANCED( ROOT_CONFIG_EXECUTABLE )
0063 FIND_PROGRAM( ROOT_CONFIG_EXECUTABLE root-config PATHS ${ROOT_DIR}/bin $ENV{ROOTSYS}/bin NO_DEFAULT_PATH )
0064 IF( NOT ROOT_DIR )
0065     FIND_PROGRAM( ROOT_CONFIG_EXECUTABLE root-config )
0066 ENDIF()
0067 
0068 
0069 IF( NOT ROOT_FIND_QUIETLY )
0070     MESSAGE( STATUS "Check for ROOT_CONFIG_EXECUTABLE: ${ROOT_CONFIG_EXECUTABLE}" )
0071 ENDIF()
0072 
0073 
0074 IF( ROOT_CONFIG_EXECUTABLE )
0075 
0076     # ==============================================
0077     # ===          ROOT_PREFIX                   ===
0078     # ==============================================
0079 
0080     # get root prefix from root-config output
0081     EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --prefix
0082         OUTPUT_VARIABLE ROOT_PREFIX
0083         RESULT_VARIABLE _exit_code
0084         OUTPUT_STRIP_TRAILING_WHITESPACE
0085     )
0086     IF( NOT _exit_code EQUAL 0 )
0087         # clear variable if root-config exits with error
0088         # it might contain garbage
0089         SET( ROOT_PREFIX )
0090     ENDIF()
0091 
0092     # PKG_ROOT variables are a cmake standard
0093     # since this package is also called ROOT the variable name
0094     # becomes ROOT_ROOT ...
0095     SET( ROOT_ROOT ${ROOT_PREFIX} )
0096 
0097 
0098 
0099     # ==============================================
0100     # ===          ROOT_BIN_DIR                  ===
0101     # ==============================================
0102 
0103     # get bindir from root-config output
0104     EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --bindir
0105         OUTPUT_VARIABLE ROOT_BIN_DIR
0106         RESULT_VARIABLE _exit_code
0107         OUTPUT_STRIP_TRAILING_WHITESPACE
0108     )
0109     IF( NOT _exit_code EQUAL 0 )
0110         # clear variable if root-config exits with error
0111         # it might contain garbage
0112         SET( ROOT_BIN_DIR )
0113     ENDIF()
0114 
0115 
0116     # ==============================================
0117     # ===         ROOT_found_version             ===
0118     # ==============================================
0119 
0120     EXECUTE_PROCESS( COMMAND ${ROOT_CONFIG_EXECUTABLE} --version
0121         OUTPUT_VARIABLE ROOT_VERSION
0122         OUTPUT_STRIP_TRAILING_WHITESPACE)
0123     IF( _exit_code EQUAL 0 )
0124         # Make ROOT-version easier to compare in cmake:
0125         STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOT_VERSION}")
0126         STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOT_VERSION}")
0127         STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOT_VERSION}")
0128         MATH(EXPR ROOT_found_version "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
0129     ENDIF()
0130 
0131 
0132     # ==============================================
0133     # ===          ROOT_EXECUTABLE               ===
0134     # ==============================================
0135 
0136 
0137     SET( ROOT_EXECUTABLE ROOT_EXECUTABLE-NOTFOUND )
0138     MARK_AS_ADVANCED( ROOT_EXECUTABLE )
0139     FIND_PROGRAM( ROOT_EXECUTABLE root PATHS ${ROOT_BIN_DIR} NO_DEFAULT_PATH )
0140 
0141     IF( NOT ROOT_FIND_QUIETLY )
0142         MESSAGE( STATUS "Check for ROOT_EXECUTABLE: ${ROOT_EXECUTABLE}" )
0143     ENDIF()
0144 
0145 
0146 
0147 
0148     # ==============================================
0149     # ===          ROOT_CINT_EXECUTABLE          ===
0150     # ==============================================
0151 
0152 
0153     # find rootcint
0154     SET( ROOT_CINT_EXECUTABLE ROOT_CINT_EXECUTABLE-NOTFOUND )
0155     MARK_AS_ADVANCED( ROOT_CINT_EXECUTABLE )
0156     FIND_PROGRAM( ROOT_CINT_EXECUTABLE NAMES rootcling PATHS ${ROOT_BIN_DIR} NO_DEFAULT_PATH )
0157 
0158     IF( NOT ROOT_FIND_QUIETLY )
0159         MESSAGE( STATUS "Check for ROOT_CINT_EXECUTABLE: ${ROOT_CINT_EXECUTABLE}" )
0160     ENDIF()
0161 
0162 
0163 
0164     # ==============================================
0165     # ===          ROOT_INCLUDE_DIR              ===
0166     # ==============================================
0167 
0168     # get include dir from root-config output
0169     EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --incdir
0170         OUTPUT_VARIABLE _inc_dir
0171         RESULT_VARIABLE _exit_code
0172         OUTPUT_STRIP_TRAILING_WHITESPACE
0173     )
0174     IF( NOT _exit_code EQUAL 0 )
0175         # clear variable if root-config exits with error
0176         # it might contain garbage
0177         SET( _inc_dir )
0178     ENDIF()
0179 
0180 
0181     SET( ROOT_INCLUDE_DIRS ROOT_INCLUDE_DIRS-NOTFOUND )
0182     MARK_AS_ADVANCED( ROOT_INCLUDE_DIRS )
0183 
0184     FIND_PATH( ROOT_INCLUDE_DIRS
0185         NAMES TH1.h
0186         PATHS ${ROOT_DIR}/include ${_inc_dir}
0187         NO_DEFAULT_PATH
0188     )
0189 
0190 
0191 
0192     # ==============================================
0193     # ===            ROOT_LIBRARIES              ===
0194     # ==============================================
0195 
0196     # get library dir from root-config output
0197     EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --libdir
0198         OUTPUT_VARIABLE ROOT_LIBRARY_DIR
0199         RESULT_VARIABLE _exit_code
0200         OUTPUT_STRIP_TRAILING_WHITESPACE
0201     )
0202     IF( NOT _exit_code EQUAL 0 )
0203         # clear variable if root-config exits with error
0204         # it might contain garbage
0205         SET( ROOT_LIBRARY_DIR )
0206     ENDIF()
0207 
0208 
0209     # ==============================================
0210     # ===            ROOT_CXX_FLAGS              ===
0211     # ==============================================
0212     # get cxx flags from root-config output
0213     EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --cflags
0214         OUTPUT_VARIABLE ROOT_CXX_FLAGS
0215         RESULT_VARIABLE _exit_code
0216         OUTPUT_STRIP_TRAILING_WHITESPACE
0217     )
0218     IF( NOT _exit_code EQUAL 0 )
0219         # clear variable if root-config exits with error
0220         # it might contain garbage
0221         SET( ROOT_CXX_FLAGS )
0222     ENDIF()
0223 
0224 
0225     # ========== standard root libraries =================
0226 
0227     # brrr, hate to do this:
0228     EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --noauxlibs --evelibs
0229         OUTPUT_VARIABLE ROOT_LIBS
0230         RESULT_VARIABLE _exit_code
0231         OUTPUT_STRIP_TRAILING_WHITESPACE
0232     )   
0233 
0234 
0235     # standard root libraries (without components)
0236     SET( _root_libnames )
0237 
0238     # get standard root libraries from 'root-config --libs' output
0239     EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --noauxlibs --libs
0240         OUTPUT_VARIABLE _aux
0241         RESULT_VARIABLE _exit_code
0242         OUTPUT_STRIP_TRAILING_WHITESPACE
0243     )
0244     IF( _exit_code EQUAL 0 )
0245         
0246         # create a list out of the output
0247         SEPARATE_ARGUMENTS( _aux )
0248 
0249         # remove first item -L compiler flag
0250         LIST( REMOVE_AT _aux 0 )
0251 
0252         FOREACH( _lib ${_aux} )
0253 
0254             # extract libnames from -l compiler flags
0255             STRING( REGEX REPLACE "^-.(.*)$" "\\1" _libname "${_lib}")
0256 
0257             # fix for some root-config versions which export -lz even if using --noauxlibs
0258             IF( NOT _libname STREQUAL "z" )
0259 
0260                 # append all library names into a list
0261                 LIST( APPEND _root_libnames ${_libname} )
0262 
0263             ENDIF()
0264 
0265         ENDFOREACH()
0266 
0267     ENDIF()
0268 
0269     # ====== DL LIBRARY ==================================================
0270     # workaround for cmake bug in 64 bit:
0271     # see: http://public.kitware.com/mantis/view.php?id=10813
0272     IF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
0273         FIND_LIBRARY( DL_LIB NAMES ${CMAKE_DL_LIBS} dl PATHS /usr/lib64 /lib64 NO_DEFAULT_PATH )
0274     ENDIF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
0275 
0276     FIND_LIBRARY( DL_LIB NAMES ${CMAKE_DL_LIBS} dl )
0277     MARK_AS_ADVANCED( DL_LIB )
0278 
0279     IF( NOT ROOT_FIND_QUIETLY )
0280         MESSAGE( STATUS "Check for libdl.so: ${DL_LIB}" )
0281     ENDIF()
0282 
0283 ENDIF( ROOT_CONFIG_EXECUTABLE )
0284 
0285 
0286 IF( ROOT_FOUND )
0287     LIST( APPEND ROOT_LIBRARIES ${DL_LIB} )
0288     # FIXME DEPRECATED
0289     SET( ROOT_DEFINITIONS "-DUSEROOT -DUSE_ROOT -DMARLIN_USE_ROOT" )
0290     MARK_AS_ADVANCED( ROOT_DEFINITIONS )
0291 
0292     # file including MACROS for generating root dictionary sources
0293     GET_FILENAME_COMPONENT( _aux ${CMAKE_CURRENT_LIST_FILE} PATH )
0294     SET( ROOT_DICT_MACROS_FILE ${_aux}/MacroRootDict.cmake )
0295 
0296 ENDIF( ROOT_FOUND )
0297 
0298 SET( ROOT_FIND_REQUIRED )