Coding convetion violations fixed.
[u/mrichter/AliRoot.git] / CMakeLists.txt
index 67fc661..0edd1fa 100644 (file)
-# -*- mode: cmake -*-
+# Top level CMakeList.txt file for the AliRoot Build System
+#
+# Author: Johny Jose (johny.jose@cern.ch)
+#         Port of previous Makefile build to cmake
 
-# Check if cmake has the required version
-Cmake_Minimum_Required(VERSION 2.6 FATAL_ERROR)
 
-# Set name of our project to AliRoot. To be done after check of cmake version
-Project(AliRoot NONE)
+cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
 
-# Set AliRoot variables
-Set(ALICE_ROOT $ENV{ALICE_ROOT})
-Set(ALICE      $ENV{ALICE})
-Set(ALICE_STATIC_BUILD ON CACHE BOOL "Build also statics libs")
+#--------------------------------------------------------------------------------#
+# Set Basic CMake Configuration                                                  #
+#--------------------------------------------------------------------------------#
 
-#Set(CMAKE_VERBOSE_MAKEFILE ON)
+project(AliRoot CXX C Fortran)
+set(ALICE_ROOT $ENV{ALICE_ROOT})
+set(ALICE $ENV{ALICE})
 
-# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ 
-Set(CMAKE_MODULE_PATH "${ALICE_ROOT}/cmake/modules")
+if(NOT ALICE)
+  message(WARNING "Environment variable ALICE is not set")
+endif(NOT ALICE)
 
-# To fix a hack that has been introduced for the Mac
-If(APPLE)
-  Set(CMAKE_INSTALL_NAME_TOOL CMAKE_INSTALL_NAME_TOOL-NOTFOUND)
-Endif(APPLE)
-
-
-# Setup ROOT
-Find_package(ROOT 5.0.0 REQUIRED)
-
-Set(CMAKE_C_COMPILER $ENV{CC})
-Enable_Language(C)
-
-Set(CMAKE_CXX_COMPILER $ENV{CXX})
-Enable_Language(CXX)
-
-Set(CMAKE_Fortran_COMPILER $ENV{F77})
-Enable_Language(Fortran)
-
-# Load some basic macros which are needed later on
-#Include(WriteConfigFile)
-Include(Dart)
-Include(ALICEMacros)
-
-# Check if the user wants to build the project in the source directory
-Check_out_of_Source_Build()
-
-# searches for needed packages
-
-Set(ALIROOT_INSTALL_DIR ${ALICE_ROOT}/${ALICE_TARGET})
-
-# Setup GEANT3
-Find_package(GEANT3 REQUIRED)
-
-# Setup RuleChecker
-Find_Package(RuleChecker)
-
-# Check if DATE is installed
-Find_Package(DATE)
-
-# Setup system dependent flags 
-SetupSystem()
-
-# Set the library version in the main CMakeLists.txt
-SET(ALIROOT_MAJOR_VERSION 0)
-SET(ALIROOT_MINOR_VERSION 0)
-SET(ALIROOT_PATCH_VERSION 0)
-SET(ALIROOT_VERSION "${ALIROOT_MAJOR_VERSION}.${ALIROOT_MINOR_VERSION}.${ALIROOT_PATCH_VERSION}")
-SET(ALIROOT_LIBRARY_PROPERTIES ${ALIROOT_LIBRARY_PROPERTIES}
-    VERSION "${ALIROOT_VERSION}"
-    SOVERSION "${ALIROOT_MAJOR_VERSION}"
-    SUFFIX ".so"
-)
-
-# Set version variables
-Find_program( READLINK_PROGRAM readlink)
-
-If(READLINK_PROGRAM) 
-  Execute_process(COMMAND readlink -f ${ALICE_ROOT} 
-    COMMAND xargs svn info
-    OUTPUT_VARIABLE _svn_out)
-Else(READLINK_PROGRAM)
-  Execute_process(COMMAND svn info ${ALICE_ROOT} 
-    OUTPUT_VARIABLE _svn_out)
-Endif(READLINK_PROGRAM)
-
-String(REGEX REPLACE "^.*Revision: ([^\n]*).*$" "\\1" 
-  ALIROOT_SVN_REVISION ${_svn_out})
-String(REGEX REPLACE "^.*URL: https://alisoft.cern.ch/AliRoot/([^\n]*).*$" "w \\1"
-  ALIROOT_SVN_BRANCH ${_svn_out})
-
-# Additional targets
-Add_Custom_Target(check-all COMMENT "Checking coding conventions")
-
-# Configure special include file
-If(UNIX)
-  Set(_in ${CMAKE_CURRENT_SOURCE_DIR}/STEER/ARVersion.h.in)
-  Set(_out ${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h)
-  Add_custom_target(ARversion ALL
-    COMMAND sed < ${_in}
-                -e "s/\\@ALIROOT_SVN_REVISION\\@/${ALIROOT_SVN_REVISION}/" 
-                -e "s/\\@ALIROOT_SVN_BRANCH\\@/${ALIROOT_SVN_BRANCH}/" 
-                -e "s/\\@ALIROOT_VERSION\\@/${ALIROOT_VERSION}/" >  ${_out})
-  Install(FILES ${_out} DESTINATION ${ALIROOT_INSTALL_DIR}/include)
-Endif(UNIX)
-
-# This would work, but just once... we want this to happen at every make
-#  Configure_file(${CMAKE_CURRENT_SOURCE_DIR}/STEER/ARVersion.h.in 
-#${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h @ONLY)
-
-# Recurse into the given subdirectories.  This does not actually
-# cause another cmake executable to run.  The same process will walk through
-# the project's entire directory structure.
-
-#Add_subdirectory(PYTHIA8) 
-#Add_subdirectory(TFluka) 
-#Add_subdirectory(THydjet) 
-
-Add_subdirectory(ACORDE) 
-Add_subdirectory(ANALYSIS) 
-Add_subdirectory(BCM) 
-Add_subdirectory(CORRFW) 
-Add_subdirectory(DPMJET) 
-Add_subdirectory(EMCAL) 
-Add_subdirectory(ESDCheck) 
-Add_subdirectory(EVE) 
-Add_subdirectory(EVGEN) 
-Add_subdirectory(FASTSIM) 
-Add_subdirectory(FMD)
-Add_subdirectory(HBTAN)
-Add_subdirectory(HERWIG) 
-Add_subdirectory(HIJING) 
-Add_subdirectory(HLT) 
-Add_subdirectory(HMPID) 
-Add_subdirectory(ITS) 
-Add_subdirectory(JETAN)
-Add_subdirectory(LHAPDF) 
-Add_subdirectory(LHC) 
-Add_subdirectory(MICROCERN) 
-Add_subdirectory(MONITOR) 
-Add_subdirectory(MUON) 
-Add_subdirectory(PHOS) 
-Add_subdirectory(PMD) 
-Add_subdirectory(PWG0) 
-Add_subdirectory(PWG1) 
-Add_subdirectory(PWG2) 
-Add_subdirectory(PWG3) 
-Add_subdirectory(PWG4)
-Add_subdirectory(PYTHIA6)
-Add_subdirectory(RALICE) 
-Add_subdirectory(RAW) 
-Add_subdirectory(STAT) 
-Add_subdirectory(STEER)
-Add_subdirectory(STRUCT) 
-Add_subdirectory(T0) 
-Add_subdirectory(TDPMjet) 
-Add_subdirectory(TEPEMGEN) 
-Add_subdirectory(THbtp) 
-Add_subdirectory(THerwig) 
-Add_subdirectory(THijing)
-Add_subdirectory(TIsajet) 
-Add_subdirectory(TOF) 
-Add_subdirectory(TPC)
-Add_subdirectory(TPHIC) 
-Add_subdirectory(TRD) 
-Add_subdirectory(TTherminator) 
-Add_subdirectory(VZERO) 
-Add_subdirectory(ZDC) 
-
-Add_subdirectory(ALIROOT)
+if(NOT ALICE_ROOT)
+  message(FATAL_ERROR "Please set ALICE_ROOT to the AliRoot source directory")
+endif(NOT ALICE_ROOT)
+
+# Set AliRoot Installation directory 
+if(NOT ALICE_INSTALL)
+  message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You can specify a different location by setting ALICE_INSTALL environment variable")
+  set(ALICE_INSTALL ${ALICE_ROOT})
+else()
+  message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
+endif(NOT ALICE_INSTALL)
+
+get_filename_component(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}" REALPATH)
+set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
+
+include(ALICE_CMake)
+
+#--------------------------------------------------------------------------------#
+# Find Packages                                                                  #
+#--------------------------------------------------------------------------------#
+
+# Subversion
+# ------------------------------
+
+find_package(Subversion REQUIRED)
+
+# ROOT
+# ------------------------------
+
+find_package(ROOT REQUIRED)
+
+# IRST Rule Checker 
+# ------------------------------
+
+find_package(RuleChecker)
+
+# DATE
+# ------------------------------ 
+
+find_package(DATE)
+
+# GEANT3
+# ------------------------------
+
+find_package(GEANT3)
+
+# AMORE
+# ------------------------------
+
+find_package(AMORE)
+
+#--------------------------------------------------------------------------------#
+# Environment/Compiler Configuration                                             #
+#--------------------------------------------------------------------------------#
+
+ALICE_CheckOutOfSourceBuild()
+ALICE_RootConfig(CMAKE_CXX_COMPILER --cxx)
+ALICE_RootConfig(CMAKE_C_COMPILER --cc)
+ALICE_RootConfig(CMAKE_Fortran_COMPILER --f77)
+ALICE_ConfigurePlatform()
+ALICE_ConfigureCompiler()
+
+
+#--------------------------------------------------------------------------------#
+# AliRoot Path Settings                                                          #
+#--------------------------------------------------------------------------------#
+
+ALICE_DevFlagsOutput()
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET}")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
+set(CMAKE_INCLUDE_EXPORT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
+file(MAKE_DIRECTORY ${CMAKE_INCLUDE_EXPORT_DIRECTORY})
+set(EXPORTDIRS "${ALICE_INSTALL}/include")
+set(BINLIBDIRS "-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+
+#--------------------------------------------------------------------------------#
+# AliRoot Modules                                                                #
+#--------------------------------------------------------------------------------#
+
+# Exclude Module from all target
+# ------------------------------
+
+#set(EXCLUDEMODULES THydjet SHUTTLE)
+
+# Standard Modules
+# ------------------------------
+set(ALIROOTMODULES STEER PHOS TRD TPC ZDC MUON PMD FMD TOF ITS ACORDE HMPID T0 BCM STRUCT VZERO THijing THbtp EMCAL THerwig TEPEMGEN FASTSIM TPHIC RAW MONITOR ANALYSIS JETAN HLT LHC ESDCheck STAT TTherminator CORRFW DPMJET TDPMjet PWG0 PWG1 PWG2 PWG3 PWG4 TRIGGER PYTHIA8 )
+
+if(THydjet)
+  list(APPEND ALIROOTMODULES THydjet)
+endif(THydjet)
+
+if(SHUTTLE)
+  list(APPEND ALIROOTMODULES SHUTTLE)
+endif(SHUTTLE)
+
+# Additional Modules
+# ------------------------------
+list(APPEND ALIROOTMODULES TUHKMgen EPOS)
+
+# EVE
+# ------------------------------
+ALICE_RootConfig(EVE --has-opengl)
+if(NOT EVE STREQUAL "no")
+  list(APPEND ALIROOTMODULES EVE)
+endif(NOT EVE STREQUAL "no")
+
+# CERN Modules
+# ------------------------------
+set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
+
+# Check for Pythia 6
+if(EXISTS ${ROOTINCDIR}/TPythia6.h)
+  set(PYTHIA6 TRUE)
+  list(APPEND CERNMODULES PYTHIA6 RALICE EVGEN)
+else()
+  message(FATAL_ERROR "ROOT must have Pythia6 enabled !")
+endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
+
+# Set Final list of modules 
+set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
+
+# Set Module directories
+set(MODDIRS ${MODULES})
+
+# Libraries for Linking
+# ------------------------------
+set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER)
+set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
+
+# Configure ARVerion.h
+# ------------------------------
+if(Subversion_FOUND)
+  Subversion_WC_INFO(${PROJECT_SOURCE_DIR} PROJECT)
+  set(ALIROOT_SVN_REVISION ${PROJECT_WC_REVISION})
+  set(ALIROOT_SVN_BRANCH ${PROJECT_WC_URL})
+  string(REGEX MATCH "[^/]+$" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
+  message(STATUS "Aliroot Revision - ${ALIROOT_SVN_REVISION} Branch - ${ALIROOT_SVN_BRANCH}")
+  if(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
+    file(REMOVE ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
+  endif(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
+  configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
+endif(Subversion_FOUND)
+
+#--------------------------------------------------------------------------------#
+# Build Modules                                                                  #
+#--------------------------------------------------------------------------------#
+
+# Module Variables
+# ------------------------------
+set(ALLLIBS)
+set(ALLEXECS)
+set(INCLUDEFILES)
+set(BINLIBS)
+set(EXPORTFILES)
+
+# Top Level Build Targets
+# ------------------------------
+
+add_custom_target(alilibs-static)
+add_custom_target(include-headers)
+add_custom_target(DA-all)
+
+
+# Add Modules
+# ------------------------------
+foreach(MODULE ${MODDIRS})
+  set(${MODULE}ALIBS)
+  configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
+  add_custom_target(${MODULE}-all ALL)
+  add_custom_target(${MODULE}-all-static)
+  add_dependencies(alilibs-static "${MODULE}-static")
+  add_subdirectory(${MODULE})
+endforeach(MODULE)
+
+if(DATE_FOUND AND AMORE_FOUND)
+  include (CMakeDA)
+endif(DATE_FOUND AND AMORE_FOUND)
+
+#--------------------------------------------------------------------------------#
+# Additional Targets                                                             #
+#--------------------------------------------------------------------------------#
+
+# AliMdc RPM
+# ------------------------------
+
+
+include (InstallRequiredSystemLibraries)
+include (CPack)