Preliminary files for CMake
[u/mrichter/AliRoot.git] / cmake / modules / FindROOT.cmake
CommitLineData
e969a926 1# -*- mode: cmake -*-
2# - Finds ROOT instalation
3# This module sets up ROOT information
4# We suppose root-config to be in the PATH. Otherwise we stop.
5
6Find_program(ROOT_CONFIG root-config)
7
8If (${ROOT_CONFIG} MATCHES "ROOT_CONFIG-NOTFOUND")
9 Set(ROOT_FOUND FALSE)
10 Message(STATUS "Install Root and make sure it is in the PATH")
11
12Else (${ROOT_CONFIG} MATCHES "ROOT_CONFIG-NOTFOUND")
13
14 Set(ROOT_FOUND TRUE)
15
16 Execute_process(
17 COMMAND root-config --prefix
18 OUTPUT_VARIABLE ROOTSYS
19 OUTPUT_STRIP_TRAILING_WHITESPACE)
20
21 Execute_process(
22 COMMAND root-config --arch
23 OUTPUT_VARIABLE ALICE_TARGET
24 OUTPUT_STRIP_TRAILING_WHITESPACE)
25
26 Execute_process(
27 COMMAND root-config --f77
28 OUTPUT_VARIABLE CMAKE_Fortran_COMPILER
29 OUTPUT_STRIP_TRAILING_WHITESPACE)
30
31 Execute_process(
32 COMMAND root-config --version
33 OUTPUT_VARIABLE ROOT_VERSION
34 OUTPUT_STRIP_TRAILING_WHITESPACE)
35
36 Execute_process(
37 COMMAND root-config --incdir
38 OUTPUT_VARIABLE ROOT_INCLUDE_DIR
39 OUTPUT_STRIP_TRAILING_WHITESPACE)
40
41 Execute_process(
42 COMMAND root-config --glibs
43 OUTPUT_VARIABLE ROOT_LIBRARIES
44 OUTPUT_STRIP_TRAILING_WHITESPACE)
45
46 Find_program(ROOTCINT rootcint)
47 If(NOT ROOTCINT)
48 Message(FATAL_ERROR "Found ROOT but not rootcint, your ROOT installation is corrupted")
49 EndIf(NOT ROOTCINT)
50
51 Set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lThread -lMinuit -lHtml -lVMC -lEG -lGeom -lTreePlayer -lXMLIO -lProof -lProofPlayer -lMLP -lSpectrum -lEve -lRGL -lGed)
52 Set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib)
53
54 # Make variables changeble to the advanced user
55 Mark_as_advanced(ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
56
57 Set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
58
59 Message(STATUS "Found Root ${ROOT_VERSION} in ${ROOTSYS}/bin/root")
60
61# we need at least version 5.00/00
62 If (NOT ROOT_MIN_VERSION)
63 Set(ROOT_MIN_VERSION "5.00/00")
64 Endif (NOT ROOT_MIN_VERSION)
65
66 # now parse the parts of the user given version string into variables
67 String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
68 String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
69 String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
70
71 # and now the version string given by qmake
72 String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOT_VERSION}")
73 String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOT_VERSION}")
74 String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOT_VERSION}")
75
76 If (found_root_major_vers LESS 5)
77 Message(FATAL_ERROR "Invalid ROOT version \"${ROOT_VERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
78 Endif(found_root_major_vers LESS 5)
79
80 # compute an overall version number which can be compared at once
81 Math(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
82 Math(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
83
84 If (found_vers LESS req_vers)
85 Set(ROOT_FOUND FALSE)
86 Set(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
87 Else (found_vers LESS req_vers)
88 Set(ROOT_FOUND TRUE)
89 Endif (found_vers LESS req_vers)
90
91Endif (${ROOT_CONFIG} MATCHES "ROOT_CONFIG-NOTFOUND")
92
93
94#####################################################################################
95
96
97Macro(ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
98
99 Set(_special_settings "${ARGV4}")
100 Set(INCLUDE_DIRS)
101 Set(infiles_nopath)
102
103 Foreach (_current_FILE ${INCLUDE_DIRS_IN})
104 Set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
105 Endforeach (_current_FILE ${INCLUDE_DIRS_IN})
106
107 String(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
108 Set(OUTFILES ${OUTFILE} ${bla})
109
110 Foreach (_current_FILE ${INFILES})
111 Get_filename_component(name_wo_path ${_current_FILE} NAME)
112 Set(infiles_nopath ${infiles_nopath} ${name_wo_path})
113 Endforeach (_current_FILE ${INFILES})
114
115 Add_custom_command(OUTPUT ${OUTFILES}
116 COMMAND DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${ROOT_LIBRARY_DIR} ${ROOTCINT}
117 ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${_special_settings} ${INCLUDE_DIRS} ${infiles_nopath} ${LINKDEF_FILE}
118 DEPENDS ${INFILES} ${LINKDEF_FILE})
119
120Endmacro(ROOT_GENERATE_DICTIONARY)