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