Index: trunk/Mars/CMakeLists.txt
===================================================================
--- trunk/Mars/CMakeLists.txt	(revision 19284)
+++ trunk/Mars/CMakeLists.txt	(revision 19286)
@@ -8,5 +8,5 @@
 # Enable debug symbols by default
 # must be done before project() statement
-SET(CMAKE_BUILD_TYPE_INIT Release) 
+SET(CMAKE_BUILD_TYPE_INIT Release)
 # (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release)
 
@@ -107,27 +107,35 @@
 
 
-# --------- config.h -------------
-
-CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/root.rc.in"     "${PROJECT_BINARY_DIR}/.rootrc")
-CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/rootlogon.C.in" "${PROJECT_BINARY_DIR}/rootlogon.C")
-
-#INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
-
-SET(CMAKE_MODULE_PATH $ENV{ROOTSYS}/etc/cmake ${CMAKE_MODULE_PATH})
-
-
-# You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:
-#   - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake
-#   - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT
-#LIST(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
-
-#---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
+# --------- ROOT -------------
+
+#IF(EXISTS "$ENV{ROOTSYS}/ROOTConfig.cmake")
+IF(DEFINED $ENV{CMAKE_PREFIX_PATH}) # -- This is supposed to be root 6 --
+   # You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:
+   #   - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake
+   #   - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT
+   LIST(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
+   #---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
+   FIND_PACKAGE(ROOT REQUIRED COMPONENTS Gui Minuit ASImage HistPainter)
+   #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
+   INCLUDE(${ROOT_USE_FILE})
+ELSE()
+   # You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:
+   #   - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake
+   #   - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT
+   SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{ROOTSYS}/etc/cmake")
+   #---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
+   FIND_PACKAGE(ROOT REQUIRED COMPONENTS Gui Minuit ASImage HistPainter)
+   # From RootUseFile.cmake (root 6)
+   INCLUDE_DIRECTORIES(${ROOT_INCLUDE_DIRS})
+   LINK_DIRECTORIES(${ROOT_LIBRARY_DIR})
+   ADD_DEFINITIONS(${ROOT_DEFINITIONS})
+   SET(CMAKE_CXX_FLAGS     "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}")
+   SET(CMAKE_C_FLAGS       "${CMAKE_C_FLAGS} ${ROOT_C_FLAGS}")
+   SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${ROOT_fortran_FLAGS}")
+ENDIF()
 
 # -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree
 # -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread
 # -lASImage -lMinuit -lHistPainter -lThread
-
-FIND_PACKAGE(ROOT REQUIRED COMPONENTS Gui Minuit ASImage HistPainter)
-
 
 #MESSAGE("INCL_DIRS: ${ROOT_INCLUDE_DIRS}")
@@ -143,11 +151,11 @@
 #ROOT_<option>_FOUND	BOOL	True for each enabled build option (e.g. cocoa, python, xrootd, etc.)
 
-#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
-#INCLUDE(${ROOT_USE_FILE})
-
 # function ROOT_GENERATE_DICTIONARY( dictionary
 #                                    header1 header2 ...
 #                                    LINKDEF linkdef1 ...
 #                                    OPTIONS opt1...)
+
+CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/root.rc.in"     "${PROJECT_BINARY_DIR}/.rootrc")
+CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/rootlogon.C.in" "${PROJECT_BINARY_DIR}/rootlogon.C")
 
 # -------------------------------------------------------
