]> Creatis software - clitk.git/blobdiff - cmake/FindROOT.cmake
STYLE: Move CMake commands to match new conventions
[clitk.git] / cmake / FindROOT.cmake
index db14f988662d855e6bd8a44129ad86137f2aa6e2..f0482994223dcde4db584e6045f1eb314290cf9e 100644 (file)
 # It tries to find the root-config script which gives you all the needed information.
 # If the system variable ROOTSYS is set this is straight forward.
 # If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH.
-# If you need an other path you should add this path to this varaible.  
+# If you need an other path you should add this path to this varaible.
 # The root-config script is then used to detect basically everything else.
 # This module defines a number of key variables and macros.
 
 
-MESSAGE(STATUS "Looking for Root...")
+message(STATUS "Looking for Root...")
 
-SET(ROOT_DEFINITIONS "")
+set(ROOT_DEFINITIONS "")
 
-SET(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
+set(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
 
-SET(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
+set(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
 
-FIND_PROGRAM(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS)
-    
-IF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
-  MESSAGE( FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please
+find_program(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS)
+
+if(${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+  message( FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please
  set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the
  subdirectory cmake/modules.")
-ELSE (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
-               MESSAGE(STATUS "root-config found")
-  STRING(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE}) 
-  SET( ENV{ROOTSYS} ${test})
+else(${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+               message(STATUS "root-config found")
+  string(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE})
+  set( ENV{ROOTSYS} ${test})
   set( ROOTSYS ${test})
-ENDIF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")  
+endif(${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+
+
+if(ROOT_CONFIG_EXECUTABLE)
 
-IF (ROOT_CONFIG_EXECUTABLE)
-   
-  SET(ROOT_FOUND FALSE)
+  set(ROOT_FOUND FALSE)
 
-  EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE ROOTVERSION)
+  exec_program(${ROOT_CONFIG_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE ROOTVERSION)
 
-  MESSAGE(STATUS "Looking for Root... - found $ENV{ROOTSYS}/bin/root")
-  MESSAGE(STATUS "Looking for Root... - version ${ROOTVERSION} ")   
+  message(STATUS "Looking for Root... - found $ENV{ROOTSYS}/bin/root")
+  message(STATUS "Looking for Root... - version ${ROOTVERSION} ")
 
   # we need at least version 5.00/00
-  IF (NOT ROOT_MIN_VERSION)
-    SET(ROOT_MIN_VERSION "5.00/00")
-  ENDIF (NOT ROOT_MIN_VERSION)
-   
+  if(NOT ROOT_MIN_VERSION)
+    set(ROOT_MIN_VERSION "5.00/00")
+  endif(NOT ROOT_MIN_VERSION)
+
   # now parse the parts of the user given version string into variables
-  STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
-   
+  string(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
+  string(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
+  string(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
+
   # and now the version string given by qmake
-  STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}")
+  string(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}")
+  string(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}")
+  string(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}")
 
-  IF (found_root_major_vers LESS 5)
-    MESSAGE( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
-  ENDIF (found_root_major_vers LESS 5)
+  if(found_root_major_vers LESS 5)
+    message( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
+  endif(found_root_major_vers LESS 5)
 
   # compute an overall version number which can be compared at once
-  MATH(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
-  MATH(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
-   
-  IF (found_vers LESS req_vers)
-    SET(ROOT_FOUND FALSE)
-    SET(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
-  ELSE (found_vers LESS req_vers)
-    SET(ROOT_FOUND TRUE)
-  ENDIF (found_vers LESS req_vers)
+  math(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
+  math(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
+
+  if(found_vers LESS req_vers)
+    set(ROOT_FOUND FALSE)
+    set(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
+  else(found_vers LESS req_vers)
+    set(ROOT_FOUND TRUE)
+  endif(found_vers LESS req_vers)
 
-ENDIF (ROOT_CONFIG_EXECUTABLE)
+endif(ROOT_CONFIG_EXECUTABLE)
 
-#MESSAGE("root found = "${ROOT_FOUND})
+#message("root found = "${ROOT_FOUND})
 
-IF (ROOT_FOUND)
+if(ROOT_FOUND)
 
   # ask root-config for the library dir
   # Set ROOT_LIBRARY_DIR
 
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
+  exec_program( ${ROOT_CONFIG_EXECUTABLE}
     ARGS "--libdir"
     OUTPUT_VARIABLE ROOT_LIBRARY_DIR_TMP )
 
-  IF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    SET(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} )
-  ELSE(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    MESSAGE("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,")
-    MESSAGE("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.")
-  ENDIF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    
+  if(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+    set(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} )
+  else(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+    message("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,")
+    message("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.")
+  endif(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+
   # ask root-config for the binary dir
-  EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE}
+  exec_program(${ROOT_CONFIG_EXECUTABLE}
     ARGS "--bindir"
     OUTPUT_VARIABLE root_bins )
-  SET(ROOT_BINARY_DIR ${root_bins})
+  set(ROOT_BINARY_DIR ${root_bins})
 
   # ask root-config for the include dir
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-    ARGS "--incdir" 
+  exec_program( ${ROOT_CONFIG_EXECUTABLE}
+    ARGS "--incdir"
     OUTPUT_VARIABLE root_headers )
-  SET(ROOT_INCLUDE_DIR ${root_headers})
+  set(ROOT_INCLUDE_DIR ${root_headers})
       # CACHE INTERNAL "")
 
   # ask root-config for the library varaibles
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-#    ARGS "--noldflags --noauxlibs --libs" 
-    ARGS "--glibs" 
+  exec_program( ${ROOT_CONFIG_EXECUTABLE}
+#    ARGS "--noldflags --noauxlibs --libs"
+    ARGS "--glibs"
     OUTPUT_VARIABLE root_flags )
 
-#  STRING(REGEX MATCHALL "([^ ])+"  root_libs_all ${root_flags})
-#  STRING(REGEX MATCHALL "-L([^ ])+"  root_library ${root_flags})
+#  string(REGEX MATCHALL "([^ ])+"  root_libs_all ${root_flags})
+#  string(REGEX MATCHALL "-L([^ ])+"  root_library ${root_flags})
 #  REMOVE_FROM_LIST(root_flags "${root_libs_all}" "${root_library}")
 
-  SET(ROOT_LIBRARIES ${root_flags})
+  set(ROOT_LIBRARIES ${root_flags})
 
   # Make variables changeble to the advanced user
-  MARK_AS_ADVANCED( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
+  mark_as_advanced( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
 
   # Set ROOT_INCLUDES
-  SET( ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
+  set( ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
 
-  SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
+  set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
 
   #######################################
   #
-  #       Check the executables of ROOT 
-  #          ( rootcint ) 
+  #       Check the executables of ROOT
+  #          ( rootcint )
   #
   #######################################
 
-  FIND_PROGRAM(ROOT_CINT_EXECUTABLE
+  find_program(ROOT_CINT_EXECUTABLE
     NAMES rootcint
     PATHS ${ROOT_BINARY_DIR}
     NO_DEFAULT_PATH
     )
 
-ENDIF (ROOT_FOUND)
+endif(ROOT_FOUND)
 
 
-#MESSAGE("icici")
+#message("icici")
 
   ###########################################
   #
@@ -146,44 +146,44 @@ ENDIF (ROOT_FOUND)
   #
   ###########################################
 
-MACRO (ROOT_GENERATE_DICTIONARY_OLD )
-   set(INFILES "")    
+macro(ROOT_GENERATE_DICTIONARY_OLD )
+
+   set(INFILES "")
 
    foreach (_current_FILE ${ARGN})
 
-     IF (${_current_FILE} MATCHES "^.*\\.h$")
-       IF (${_current_FILE} MATCHES "^.*Link.*$")
+     if(${_current_FILE} MATCHES "^.*\\.h$")
+       if(${_current_FILE} MATCHES "^.*Link.*$")
          set(LINKDEF_FILE ${_current_FILE})
-       ELSE (${_current_FILE} MATCHES "^.*Link.*$")
+       else(${_current_FILE} MATCHES "^.*Link.*$")
          set(INFILES ${INFILES} ${_current_FILE})
-       ENDIF (${_current_FILE} MATCHES "^.*Link.*$")
-     ELSE (${_current_FILE} MATCHES "^.*\\.h$")
-       IF (${_current_FILE} MATCHES "^.*\\.cxx$")
+       endif(${_current_FILE} MATCHES "^.*Link.*$")
+     else(${_current_FILE} MATCHES "^.*\\.h$")
+       if(${_current_FILE} MATCHES "^.*\\.cxx$")
          set(OUTFILE ${_current_FILE})
-       ELSE (${_current_FILE} MATCHES "^.*\\.cxx$")
-         set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})   
-       ENDIF (${_current_FILE} MATCHES "^.*\\.cxx$")
-     ENDIF (${_current_FILE} MATCHES "^.*\\.h$")
-     
+       else(${_current_FILE} MATCHES "^.*\\.cxx$")
+         set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
+       endif(${_current_FILE} MATCHES "^.*\\.cxx$")
+     endif(${_current_FILE} MATCHES "^.*\\.h$")
+
    endforeach (_current_FILE ${ARGN})
-   
-#  MESSAGE("INFILES: ${INFILES}")
-#  MESSAGE("OutFILE: ${OUTFILE}")
-#  MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}")
-#  MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}")
 
-   STRING(REGEX REPLACE "(^.*).cxx" "\\1.h" bla "${OUTFILE}")
-#   MESSAGE("BLA: ${bla}")
-   SET (OUTFILES ${OUTFILE} ${bla})
+#  message("INFILES: ${INFILES}")
+#  message("OutFILE: ${OUTFILE}")
+#  message("LINKDEF_FILE: ${LINKDEF_FILE}")
+#  message("INCLUDE_DIRS: ${INCLUDE_DIRS}")
 
-   ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
+   string(REGEX REPLACE "(^.*).cxx" "\\1.h" bla "${OUTFILE}")
+#   message("BLA: ${bla}")
+   set(OUTFILES ${OUTFILE} ${bla})
+
+   add_custom_command(OUTPUT ${OUTFILES}
       COMMAND ${ROOT_CINT_EXECUTABLE}
       ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES})
 
-#   MESSAGE("ROOT_CINT_EXECUTABLE has created the dictionary ${OUTFILE}")
+#   message("ROOT_CINT_EXECUTABLE has created the dictionary ${OUTFILE}")
 
-ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD)
+endmacro(ROOT_GENERATE_DICTIONARY_OLD)
 
   ###########################################
   #
@@ -191,28 +191,28 @@ ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD)
   #
   ###########################################
 
-MACRO (ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
+macro(ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
+
   set(INCLUDE_DIRS)
 
   foreach (_current_FILE ${INCLUDE_DIRS_IN})
-    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})   
+    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
   endforeach (_current_FILE ${INCLUDE_DIRS_IN})
 
-#  MESSAGE("INFILES: ${INFILES}")
-#  MESSAGE("OutFILE: ${OUTFILE}")
-#  MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}")
-#  MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}")
 
-  STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
-#  MESSAGE("BLA: ${bla}")
-  SET (OUTFILES ${OUTFILE} ${bla})
+#  message("INFILES: ${INFILES}")
+#  message("OutFILE: ${OUTFILE}")
+#  message("LINKDEF_FILE: ${LINKDEF_FILE}")
+#  message("INCLUDE_DIRS: ${INCLUDE_DIRS}")
+
+  string(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
+#  message("BLA: ${bla}")
+  set(OUTFILES ${OUTFILE} ${bla})
 
-  ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
+  add_custom_command(OUTPUT ${OUTFILES}
      COMMAND ${ROOT_CINT_EXECUTABLE}
      ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES})
 
-ENDMACRO (ROOT_GENERATE_DICTIONARY)
+endmacro(ROOT_GENERATE_DICTIONARY)
 
-#MESSAGE("la")
+#message("la")