Fixed issue with DATE which caused SLC 4 builds to fail
[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
84641bd5 28 OUTPUT_VARIABLE _f77
e969a926 29 OUTPUT_STRIP_TRAILING_WHITESPACE)
46e443ec 30 If(APPLE)
31 Execute_process(
32 COMMAND which ${_f77}
33 OUTPUT_VARIABLE _f77path
34 OUTPUT_STRIP_TRAILING_WHITESPACE)
35 Set(ENV{F77} ${_f77path})
36 Else(APPLE)
37 Set(ENV{F77} ${_f77})
38 Endif(APPLE)
84641bd5 39
40 Execute_process(
41 COMMAND root-config --cc
42 OUTPUT_VARIABLE _cc
43 OUTPUT_STRIP_TRAILING_WHITESPACE)
46e443ec 44 If(APPLE)
45 Execute_process(
46 COMMAND which ${_cc}
47 OUTPUT_VARIABLE _ccpath
48 OUTPUT_STRIP_TRAILING_WHITESPACE)
49 Set(ENV{CC} ${_ccpath})
50 Else(APPLE)
51 Set(ENV{CC} ${_cc})
52 Endif(APPLE)
84641bd5 53
54 Execute_process(
55 COMMAND root-config --cxx
56 OUTPUT_VARIABLE _cxx
57 OUTPUT_STRIP_TRAILING_WHITESPACE)
46e443ec 58 If(APPLE)
59 Execute_process(
60 COMMAND which ${_cxx}
61 OUTPUT_VARIABLE _cxxpath
62 OUTPUT_STRIP_TRAILING_WHITESPACE)
63 Set(ENV{CXX} ${_cxxpath})
64 Else(APPLE)
65 Set(ENV{CXX} ${_cxx})
66 Endif(APPLE)
e969a926 67
68 Execute_process(
69 COMMAND root-config --version
70 OUTPUT_VARIABLE ROOT_VERSION
71 OUTPUT_STRIP_TRAILING_WHITESPACE)
72
73 Execute_process(
74 COMMAND root-config --incdir
75 OUTPUT_VARIABLE ROOT_INCLUDE_DIR
76 OUTPUT_STRIP_TRAILING_WHITESPACE)
77
78 Execute_process(
79 COMMAND root-config --glibs
80 OUTPUT_VARIABLE ROOT_LIBRARIES
81 OUTPUT_STRIP_TRAILING_WHITESPACE)
82
83 Find_program(ROOTCINT rootcint)
84 If(NOT ROOTCINT)
85 Message(FATAL_ERROR "Found ROOT but not rootcint, your ROOT installation is corrupted")
86 EndIf(NOT ROOTCINT)
87
84641bd5 88 Set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lThread -lMinuit -lHtml -lVMC -lEG -lGeom -lTreePlayer -lXMLIO -lProof)
89 Set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lProofPlayer -lMLP -lSpectrum -lEve -lRGL -lGed -lXMLParser -lPhysics)
e969a926 90 Set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib)
91
92 # Make variables changeble to the advanced user
93 Mark_as_advanced(ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
94
95 Set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
96
97 Message(STATUS "Found Root ${ROOT_VERSION} in ${ROOTSYS}/bin/root")
98
99# we need at least version 5.00/00
100 If (NOT ROOT_MIN_VERSION)
101 Set(ROOT_MIN_VERSION "5.00/00")
102 Endif (NOT ROOT_MIN_VERSION)
103
104 # now parse the parts of the user given version string into variables
105 String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
106 String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
107 String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
108
109 # and now the version string given by qmake
110 String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOT_VERSION}")
111 String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOT_VERSION}")
112 String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOT_VERSION}")
113
114 If (found_root_major_vers LESS 5)
115 Message(FATAL_ERROR "Invalid ROOT version \"${ROOT_VERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
116 Endif(found_root_major_vers LESS 5)
117
118 # compute an overall version number which can be compared at once
119 Math(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
120 Math(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
121
122 If (found_vers LESS req_vers)
123 Set(ROOT_FOUND FALSE)
124 Set(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
125 Else (found_vers LESS req_vers)
126 Set(ROOT_FOUND TRUE)
127 Endif (found_vers LESS req_vers)
128
129Endif (${ROOT_CONFIG} MATCHES "ROOT_CONFIG-NOTFOUND")
130
131
132#####################################################################################
133
134
135Macro(ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
136
137 Set(_special_settings "${ARGV4}")
138 Set(INCLUDE_DIRS)
139 Set(infiles_nopath)
140
141 Foreach (_current_FILE ${INCLUDE_DIRS_IN})
142 Set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
143 Endforeach (_current_FILE ${INCLUDE_DIRS_IN})
f180903d 144 list(APPEND INCLUDE_DIRS "-Iinclude" "-isystem${ROOT_INCLUDE_DIR}")
e969a926 145 String(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
146 Set(OUTFILES ${OUTFILE} ${bla})
147
148 Foreach (_current_FILE ${INFILES})
f180903d 149 string(REGEX MATCH "Ali" ALICE ${_current_FILE})
150#Filter Non-ALICE files
151 if(ALICE)
152 Get_filename_component(name_wo_path ${_current_FILE} NAME)
153 Set(infiles_nopath ${infiles_nopath} ${name_wo_path})
154 endif(ALICE)
e969a926 155 Endforeach (_current_FILE ${INFILES})
156
84641bd5 157 Get_property(_defs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
f180903d 158 set(_ddefs)
84641bd5 159 Foreach (_def ${_defs})
f180903d 160 set(_ddefs "${_ddefs} -D${_def}")
84641bd5 161 Endforeach (_def ${_defs})
f180903d 162#Remove DALI_DIM for dictionaries
163 string(REGEX REPLACE "-DALI_DIM" "" _ddefs ${_ddefs})
84641bd5 164 Separate_arguments(_ddefs)
e969a926 165 Add_custom_command(OUTPUT ${OUTFILES}
166 COMMAND DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${ROOT_LIBRARY_DIR} ${ROOTCINT}
f180903d 167 ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${_ddefs} ${__DATEFLAGS} ${_special_settings} ${INCLUDE_DIRS} ${infiles_nopath} ${LINKDEF_FILE}
e969a926 168 DEPENDS ${INFILES} ${LINKDEF_FILE})
169
170Endmacro(ROOT_GENERATE_DICTIONARY)