| 1 |
mayorov |
1.1 |
# - Find ROOT instalation |
| 2 |
|
|
# This module tries to find the ROOT installation on your system. |
| 3 |
|
|
# It tries to find the root-config script which gives you all the needed information. |
| 4 |
|
|
# If the system variable ROOTSYS is set this is straight forward. |
| 5 |
|
|
# If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH. |
| 6 |
|
|
# If you need an other path you should add this path to this varaible. |
| 7 |
|
|
# The root-config script is then used to detect basically everything else. |
| 8 |
|
|
# This module defines a number of key variables and macros. |
| 9 |
|
|
|
| 10 |
|
|
# F.Uhlig@gsi.de (fairroot.gsi.de) |
| 11 |
|
|
|
| 12 |
|
|
|
| 13 |
|
|
MESSAGE(STATUS "Looking for Root...") |
| 14 |
|
|
|
| 15 |
|
|
SET(ROOT_CONFIG_SEARCHPATH |
| 16 |
|
|
${SIMPATH}/tools/root/bin |
| 17 |
|
|
$ENV{ROOTSYS}/bin |
| 18 |
|
|
) |
| 19 |
|
|
|
| 20 |
|
|
SET(ROOT_DEFINITIONS "") |
| 21 |
|
|
|
| 22 |
|
|
SET(ROOT_INSTALLED_VERSION_TOO_OLD FALSE) |
| 23 |
|
|
|
| 24 |
|
|
SET(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND) |
| 25 |
|
|
|
| 26 |
|
|
FIND_PROGRAM(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS |
| 27 |
|
|
${ROOT_CONFIG_SEARCHPATH} |
| 28 |
|
|
NO_DEFAULT_PATH) |
| 29 |
|
|
|
| 30 |
|
|
IF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND") |
| 31 |
|
|
MESSAGE( FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please |
| 32 |
|
|
set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the |
| 33 |
|
|
subdirectory cmake/modules.") |
| 34 |
|
|
ELSE (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND") |
| 35 |
|
|
STRING(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE}) |
| 36 |
|
|
SET( ENV{ROOTSYS} ${test}) |
| 37 |
|
|
set( ROOTSYS ${test}) |
| 38 |
|
|
ENDIF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND") |
| 39 |
|
|
|
| 40 |
|
|
|
| 41 |
|
|
IF (ROOT_CONFIG_EXECUTABLE) |
| 42 |
|
|
|
| 43 |
|
|
SET(ROOT_FOUND FALSE) |
| 44 |
|
|
|
| 45 |
|
|
EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE ROOTVERSION) |
| 46 |
|
|
|
| 47 |
|
|
MESSAGE(STATUS "Looking for Root... - found $ENV{ROOTSYS}/bin/root") |
| 48 |
|
|
MESSAGE(STATUS "Looking for Root... - version ${ROOTVERSION} ") |
| 49 |
|
|
|
| 50 |
|
|
# we need at least version 5.00/00 |
| 51 |
|
|
IF (NOT ROOT_MIN_VERSION) |
| 52 |
|
|
SET(ROOT_MIN_VERSION "5.00/00") |
| 53 |
|
|
ENDIF (NOT ROOT_MIN_VERSION) |
| 54 |
|
|
|
| 55 |
|
|
# now parse the parts of the user given version string into variables |
| 56 |
|
|
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}") |
| 57 |
|
|
STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}") |
| 58 |
|
|
STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}") |
| 59 |
|
|
|
| 60 |
|
|
# and now the version string given by qmake |
| 61 |
|
|
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}") |
| 62 |
|
|
STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}") |
| 63 |
|
|
STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}") |
| 64 |
|
|
|
| 65 |
|
|
IF (found_root_major_vers LESS 5) |
| 66 |
|
|
MESSAGE( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"") |
| 67 |
|
|
ENDIF (found_root_major_vers LESS 5) |
| 68 |
|
|
|
| 69 |
|
|
# compute an overall version number which can be compared at once |
| 70 |
|
|
MATH(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}") |
| 71 |
|
|
MATH(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}") |
| 72 |
|
|
|
| 73 |
|
|
IF (found_vers LESS req_vers) |
| 74 |
|
|
SET(ROOT_FOUND FALSE) |
| 75 |
|
|
SET(ROOT_INSTALLED_VERSION_TOO_OLD TRUE) |
| 76 |
|
|
ELSE (found_vers LESS req_vers) |
| 77 |
|
|
SET(ROOT_FOUND TRUE) |
| 78 |
|
|
ENDIF (found_vers LESS req_vers) |
| 79 |
|
|
|
| 80 |
|
|
ENDIF (ROOT_CONFIG_EXECUTABLE) |
| 81 |
|
|
|
| 82 |
|
|
|
| 83 |
|
|
IF (ROOT_FOUND) |
| 84 |
|
|
|
| 85 |
|
|
# ask root-config for the library dir |
| 86 |
|
|
# Set ROOT_LIBRARY_DIR |
| 87 |
|
|
|
| 88 |
|
|
EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE} |
| 89 |
|
|
ARGS "--libdir" |
| 90 |
|
|
OUTPUT_VARIABLE ROOT_LIBRARY_DIR_TMP ) |
| 91 |
|
|
|
| 92 |
|
|
IF(EXISTS "${ROOT_LIBRARY_DIR_TMP}") |
| 93 |
|
|
SET(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} ) |
| 94 |
|
|
ELSE(EXISTS "${ROOT_LIBRARY_DIR_TMP}") |
| 95 |
|
|
MESSAGE("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,") |
| 96 |
|
|
MESSAGE("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.") |
| 97 |
|
|
ENDIF(EXISTS "${ROOT_LIBRARY_DIR_TMP}") |
| 98 |
|
|
|
| 99 |
|
|
# ask root-config for the binary dir |
| 100 |
|
|
EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} |
| 101 |
|
|
ARGS "--bindir" |
| 102 |
|
|
OUTPUT_VARIABLE root_bins ) |
| 103 |
|
|
SET(ROOT_BINARY_DIR ${root_bins}) |
| 104 |
|
|
|
| 105 |
|
|
# ask root-config for the include dir |
| 106 |
|
|
EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE} |
| 107 |
|
|
ARGS "--incdir" |
| 108 |
|
|
OUTPUT_VARIABLE root_headers ) |
| 109 |
|
|
SET(ROOT_INCLUDE_DIR ${root_headers}) |
| 110 |
|
|
# CACHE INTERNAL "") |
| 111 |
|
|
|
| 112 |
|
|
# ask root-config for the library varaibles |
| 113 |
|
|
EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE} |
| 114 |
|
|
# ARGS "--noldflags --noauxlibs --libs" |
| 115 |
|
|
ARGS "--glibs" |
| 116 |
|
|
OUTPUT_VARIABLE root_flags ) |
| 117 |
|
|
|
| 118 |
|
|
# STRING(REGEX MATCHALL "([^ ])+" root_libs_all ${root_flags}) |
| 119 |
|
|
# STRING(REGEX MATCHALL "-L([^ ])+" root_library ${root_flags}) |
| 120 |
|
|
# REMOVE_FROM_LIST(root_flags "${root_libs_all}" "${root_library}") |
| 121 |
|
|
|
| 122 |
|
|
SET(ROOT_LIBRARIES ${root_flags}) |
| 123 |
|
|
|
| 124 |
|
|
# Make variables changeble to the advanced user |
| 125 |
|
|
MARK_AS_ADVANCED( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS) |
| 126 |
|
|
|
| 127 |
|
|
# Set ROOT_INCLUDES |
| 128 |
|
|
SET( ROOT_INCLUDES ${ROOT_INCLUDE_DIR}) |
| 129 |
|
|
|
| 130 |
|
|
SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR}) |
| 131 |
|
|
|
| 132 |
|
|
####################################### |
| 133 |
|
|
# |
| 134 |
|
|
# Check the executables of ROOT |
| 135 |
|
|
# ( rootcint ) |
| 136 |
|
|
# |
| 137 |
|
|
####################################### |
| 138 |
|
|
|
| 139 |
|
|
FIND_PROGRAM(ROOT_CINT_EXECUTABLE |
| 140 |
|
|
NAMES rootcint |
| 141 |
|
|
PATHS ${ROOT_BINARY_DIR} |
| 142 |
|
|
NO_DEFAULT_PATH |
| 143 |
|
|
) |
| 144 |
|
|
|
| 145 |
|
|
ENDIF (ROOT_FOUND) |
| 146 |
|
|
|
| 147 |
|
|
|
| 148 |
|
|
|
| 149 |
|
|
########################################### |
| 150 |
|
|
# |
| 151 |
|
|
# Macros for building ROOT dictionary |
| 152 |
|
|
# |
| 153 |
|
|
########################################### |
| 154 |
|
|
|
| 155 |
|
|
MACRO (ROOT_GENERATE_DICTIONARY_OLD ) |
| 156 |
|
|
|
| 157 |
|
|
set(INFILES "") |
| 158 |
|
|
|
| 159 |
|
|
foreach (_current_FILE ${ARGN}) |
| 160 |
|
|
|
| 161 |
|
|
IF (${_current_FILE} MATCHES "^.*\\.h$") |
| 162 |
|
|
IF (${_current_FILE} MATCHES "^.*Link.*$") |
| 163 |
|
|
set(LINKDEF_FILE ${_current_FILE}) |
| 164 |
|
|
ELSE (${_current_FILE} MATCHES "^.*Link.*$") |
| 165 |
|
|
set(INFILES ${INFILES} ${_current_FILE}) |
| 166 |
|
|
ENDIF (${_current_FILE} MATCHES "^.*Link.*$") |
| 167 |
|
|
ELSE (${_current_FILE} MATCHES "^.*\\.h$") |
| 168 |
|
|
IF (${_current_FILE} MATCHES "^.*\\.cxx$") |
| 169 |
|
|
set(OUTFILE ${_current_FILE}) |
| 170 |
|
|
ELSE (${_current_FILE} MATCHES "^.*\\.cxx$") |
| 171 |
|
|
set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE}) |
| 172 |
|
|
ENDIF (${_current_FILE} MATCHES "^.*\\.cxx$") |
| 173 |
|
|
ENDIF (${_current_FILE} MATCHES "^.*\\.h$") |
| 174 |
|
|
|
| 175 |
|
|
endforeach (_current_FILE ${ARGN}) |
| 176 |
|
|
|
| 177 |
|
|
# MESSAGE("INFILES: ${INFILES}") |
| 178 |
|
|
# MESSAGE("OutFILE: ${OUTFILE}") |
| 179 |
|
|
# MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}") |
| 180 |
|
|
# MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}") |
| 181 |
|
|
|
| 182 |
|
|
STRING(REGEX REPLACE "(^.*).cxx" "\\1.h" bla "${OUTFILE}") |
| 183 |
|
|
# MESSAGE("BLA: ${bla}") |
| 184 |
|
|
SET (OUTFILES ${OUTFILE} ${bla}) |
| 185 |
|
|
|
| 186 |
|
|
ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES} |
| 187 |
|
|
COMMAND ${ROOT_CINT_EXECUTABLE} |
| 188 |
|
|
ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES}) |
| 189 |
|
|
|
| 190 |
|
|
# MESSAGE("ROOT_CINT_EXECUTABLE has created the dictionary ${OUTFILE}") |
| 191 |
|
|
|
| 192 |
|
|
ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD) |
| 193 |
|
|
|
| 194 |
|
|
########################################### |
| 195 |
|
|
# |
| 196 |
|
|
# Macros for building ROOT dictionary |
| 197 |
|
|
# |
| 198 |
|
|
########################################### |
| 199 |
|
|
|
| 200 |
|
|
MACRO (ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN) |
| 201 |
|
|
|
| 202 |
|
|
set(INCLUDE_DIRS) |
| 203 |
|
|
|
| 204 |
|
|
foreach (_current_FILE ${INCLUDE_DIRS_IN}) |
| 205 |
|
|
set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE}) |
| 206 |
|
|
endforeach (_current_FILE ${INCLUDE_DIRS_IN}) |
| 207 |
|
|
|
| 208 |
|
|
|
| 209 |
|
|
MESSAGE("INFILES: ${INFILES}") |
| 210 |
|
|
MESSAGE("OutFILE: ${OUTFILE}") |
| 211 |
|
|
MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}") |
| 212 |
|
|
MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}") |
| 213 |
|
|
|
| 214 |
|
|
STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}") |
| 215 |
|
|
# MESSAGE("BLA: ${bla}") |
| 216 |
|
|
SET (OUTFILES ${OUTFILE} ${bla}) |
| 217 |
|
|
|
| 218 |
|
|
|
| 219 |
|
|
if (CMAKE_SYSTEM_NAME MATCHES Linux) |
| 220 |
|
|
ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES} |
| 221 |
|
|
COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} |
| 222 |
|
|
ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE}) |
| 223 |
|
|
else (CMAKE_SYSTEM_NAME MATCHES Linux) |
| 224 |
|
|
if (CMAKE_SYSTEM_NAME MATCHES Darwin) |
| 225 |
|
|
ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES} |
| 226 |
|
|
COMMAND DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} |
| 227 |
|
|
ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE}) |
| 228 |
|
|
endif (CMAKE_SYSTEM_NAME MATCHES Darwin) |
| 229 |
|
|
endif (CMAKE_SYSTEM_NAME MATCHES Linux) |
| 230 |
|
|
|
| 231 |
|
|
ENDMACRO (ROOT_GENERATE_DICTIONARY) |
| 232 |
|
|
|
| 233 |
|
|
MACRO (GENERATE_ROOT_TEST_SCRIPT SCRIPT_FULL_NAME) |
| 234 |
|
|
|
| 235 |
|
|
get_filename_component(path_name ${SCRIPT_FULL_NAME} PATH) |
| 236 |
|
|
get_filename_component(file_extension ${SCRIPT_FULL_NAME} EXT) |
| 237 |
|
|
get_filename_component(file_name ${SCRIPT_FULL_NAME} NAME_WE) |
| 238 |
|
|
set(shell_script_name "${file_name}.sh") |
| 239 |
|
|
|
| 240 |
|
|
#MESSAGE("PATH: ${path_name}") |
| 241 |
|
|
#MESSAGE("Ext: ${file_extension}") |
| 242 |
|
|
#MESSAGE("Name: ${file_name}") |
| 243 |
|
|
#MESSAGE("Shell Name: ${shell_script_name}") |
| 244 |
|
|
|
| 245 |
|
|
string(REPLACE ${PROJECT_SOURCE_DIR} |
| 246 |
|
|
${PROJECT_BINARY_DIR} new_path ${path_name} |
| 247 |
|
|
) |
| 248 |
|
|
|
| 249 |
|
|
#MESSAGE("New PATH: ${new_path}") |
| 250 |
|
|
|
| 251 |
|
|
file(MAKE_DIRECTORY ${new_path}/data) |
| 252 |
|
|
|
| 253 |
|
|
CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH}) |
| 254 |
|
|
set(MY_LD_LIBRARY_PATH ${output}) |
| 255 |
|
|
set(my_script_name ${SCRIPT_FULL_NAME}) |
| 256 |
|
|
|
| 257 |
|
|
if(CMAKE_SYSTEM MATCHES Darwin) |
| 258 |
|
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/root_macro_macos.sh.in |
| 259 |
|
|
${new_path}/${shell_script_name} |
| 260 |
|
|
) |
| 261 |
|
|
else(CMAKE_SYSTEM MATCHES Darwin) |
| 262 |
|
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/root_macro.sh.in |
| 263 |
|
|
${new_path}/${shell_script_name} |
| 264 |
|
|
) |
| 265 |
|
|
endif(CMAKE_SYSTEM MATCHES Darwin) |
| 266 |
|
|
|
| 267 |
|
|
EXEC_PROGRAM(/bin/chmod ARGS "u+x ${new_path}/${shell_script_name}") |
| 268 |
|
|
|
| 269 |
|
|
ENDMACRO (GENERATE_ROOT_TEST_SCRIPT) |