consolidate zero-length arrays (aka struct hack)
[u/mrichter/AliRoot.git] / CMakeLists.txt
index 0f41946..d0307e6 100644 (file)
 # -*- mode: cmake -*-
 
-# Check if cmake has the required version
-Cmake_Minimum_Required(VERSION 2.6 FATAL_ERROR)
+# Top level CMakeList.txt file for the AliRoot Build System
+#
+# Author: Johny Jose (johny.jose@cern.ch)
+#         Port of previous Makefile build to cmake
+
+
+cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
+
+#--------------------------------------------------------------------------------#
+# Set Basic CMake Configuration                                                  #
+#--------------------------------------------------------------------------------#
+
+project(AliRoot CXX C Fortran)
+
+# Environment variables
+set(ALICE $ENV{ALICE})
+if(NOT ALICE)
+  message(WARNING "Environment variable ALICE is not set")
+endif(NOT ALICE)
+
+set(ALICE_ROOT $ENV{ALICE_ROOT})
+if(NOT ALICE_ROOT)
+  message(FATAL_ERROR "Please set ALICE_ROOT to the AliRoot source directory")
+endif(NOT ALICE_ROOT)
+
+set(ALICE_INSTALL $ENV{ALICE_INSTALL})
+# Set AliRoot Installation directory 
+# If CMAKE_INSTALL_PREFIX was not set than we set it to ALICE_INSTALL. 
+# If ALICE_INSTALL was not defined than it will default to source directory
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+    if(ALICE_INSTALL)
+       message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
+    else()
+       message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You
+       can specify a different location by passing -DCMAKE_INSTALL_PREFIX or
+       by setting ALICE_INSTALL environment variable")
+       set(ALICE_INSTALL ${ALICE_ROOT})
+       if(${ALICE_INSTALL} STREQUAL ${CMAKE_BINARY_DIR})
+           message(FATAL_ERROR "The install directory must differ from the
+           build directory")
+       endif()
+    endif()
+    set(CMAKE_INSTALL_PREFIX ${ALICE_INSTALL} CACHE STRING "Install dir" FORCE)
+endif()
+
+
+# Environment for SHUTTLE
+set(DIMDIR $ENV{DIMDIR})
+set(ODIR $ENV{ODIR})
+
+get_filename_component(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}" REALPATH)
+set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
+set(CPACK_COMPONENTS_ALL MDC)
+
+include(ALICE_CMake)
+
+#--------------------------------------------------------------------------------#
+# Find Packages                                                                  #
+#--------------------------------------------------------------------------------#
+
+# Subversion
+# ------------------------------
+
+find_package(Subversion REQUIRED)
+
+# ROOT
+# ------------------------------
+
+find_package(ROOT REQUIRED)
+
+# IRST Rule Checker 
+# ------------------------------
 
-# Set name of our project to AliRoot. To be done after check of cmake version
-Project(AliRoot NONE)
+find_package(RuleChecker)
 
-# Set AliRoot variables
-Set(ALICE_ROOT $ENV{ALICE_ROOT})
-Set(ALICE      $ENV{ALICE})
-Set(ALICE_STATIC_BUILD OFF CACHE BOOL "Build also statics libs")
+# DATE
+# ------------------------------ 
 
-MESSAGE("ALICE_ROOT: ${ALICE_ROOT}")
-Set(CMAKE_VERBOSE_MAKEFILE ON)
+find_package(DATE)
 
-# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ 
-SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
-SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
-Set(CMAKE_MODULE_PATH "${ALICE_ROOT}/cmake/modules")
+# GEANT3
+# ------------------------------
 
-# 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)
+find_package(GEANT3)
 
-# Setup ROOT
-Find_package(ROOT 5.0.0 REQUIRED)
+# AMORE
+# ------------------------------
 
-Set(CMAKE_C_COMPILER $ENV{CC})
-Enable_Language(C)
+find_package(AMORE)
 
-Set(CMAKE_CXX_COMPILER $ENV{CXX})
-Enable_Language(CXX)
+# AliRoot CPack configuration                                                    
+#-------------------------------
 
-Set(CMAKE_Fortran_COMPILER $ENV{F77})
-Enable_Language(Fortran)
+find_package(CPack)
 
-# Load some basic macros which are needed later on
-#Include(WriteConfigFile)
-Include(Dart)
-Include(ALICEMacros)
+# ZeroMQ
+# ------------------------------
+find_package(ZeroMQ)
 
-# Check if the user wants to build the project in the source directory
-Check_out_of_Source_Build()
+# fastjet
+# ------------------------------
+find_package(FASTJET)
 
-# searches for needed packages
+#--------------------------------------------------------------------------------#
+# Environment/Compiler Configuration                                             #
+#--------------------------------------------------------------------------------#
 
-Set(ALIROOT_INSTALL_DIR ${ALICE_ROOT}/${ALICE_TARGET})
+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                                                          #
+#--------------------------------------------------------------------------------#
 
-# Setup GEANT3
-Find_package(GEANT3 REQUIRED)
+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}")
 
-# Setup RuleChecker
-Find_Package(RuleChecker)
 
-# Check if DATE is installed
-Find_Package(DATE)
+#--------------------------------------------------------------------------------#
+# AliRoot Modules                                                                #
+#--------------------------------------------------------------------------------#
 
-# Setup system dependent flags 
-SetupSystem()
+# Exclude Module from all target
+# ------------------------------
 
+#set(EXCLUDEMODULES THydjet SHUTTLE)
 
-Option(GENERATE_FILES "Generate CMake input files from package files" OFF)
-if(GENERATE_FILES)
-  Include(CreateSubCMakeFiles)
-  CreateSubCMakeFiles()
-endif(GENERATE_FILES)
 
-# 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"
+# Standard Modules
+# ------------------------------
+set(ALIROOTMODULES STEER PHOS TRD TPC ZDC MUON PMD FMD TOF ITS AD ACORDE HMPID T0 BCM STRUCT VZERO THijing THbtp EMCAL THerwig TEPEMGEN FASTSIM TPHIC RAW MONITOR ANALYSIS JETAN HLT STAT TTherminator CORRFW DPMJET TDPMjet STARLIGHT PWGPP PWG PWGCF PWGGA PWGHF PWGDQ PWGJE PWGLF PWGUD TRIGGER PYTHIA8 TAmpt OADB MFT TEvtGen FIT)
+
+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 EVGEN)
+elseif(NOT NOPYTHIA)
+  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 AD ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER MFT)
+set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
+
+# Configure ARVerion.h
+# ------------------------------
+#If the sources were taken from Git
+if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
+ include(GetGitRevisionDescription)
+ find_package(Git)
+ if(GIT_FOUND)
+  get_git_head_revision(GIT_REFSPEC GIT_SHA1)
+  message(STATUS "Aliroot branch - ${GIT_REFSPEC} Revision - ${GIT_SHA1} ")
+
+  STRING(REGEX REPLACE "^(.+/)(.+)/(.*)$" "\\2" BRANCH_TYPE "${GIT_REFSPEC}" )
+  
+  if(BRANCH_TYPE STREQUAL "heads")
+   set(ALIROOT_REVISION "ThisIsaBranchNoRevisionProvided")
+  else()
+   set(ALIROOT_REVISION ${GIT_SHA1})
+  endif()
+
+  STRING(REGEX REPLACE "^(.+/)(.+/)(.*)$" "\\3" SHORT_BRANCH "${GIT_REFSPEC}" )
+
+  set(ALIROOT_BRANCH ${SHORT_BRANCH})
+
+ else()
+  message("Git not installed. I can't tell you which revision you are using!")
+  endif(GIT_FOUND)
+else()
+ message("AliRoot sources not downloaded from a Version Control System. I can't tell which revision you are using!")
+endif(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
+
+configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
+
+string (REPLACE "-" "." ALIROOT_BRANCH_SPEC "${ALIROOT_BRANCH}")
+
+#--------------------------------------------------------------------------------#
+# 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 ALL)
+add_custom_target(DA-all)
+add_custom_target(check-all) 
+add_custom_target(check-hxml)
+add_custom_target(smell-all) 
+add_custom_target(htmldoc) 
+add_custom_target(par-all)
+add_custom_target(test-par-all)
+
+#NY file(GLOB CFILES_LIST ${CMAKE_SOURCE_DIR}/macros/*.C)
+
+add_custom_command(TARGET htmldoc
+                  PRE_BUILD
+                  COMMAND mkdir -p html
+                  COMMAND rm -rf html/roothtml
+                  COMMAND rm -f html/picts
+                  COMMAND cd html && aliroot -q -b mkhtml.C\\\(0,1\\\)
+                  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+# Include Vc, which provides the static libVc and the relevant CMake macros
+include(Vc/Vc.cmake)
+add_subdirectory(Vc)
+
+# Add Modules  
+# ------------------------------
+foreach(MODULE ${MODDIRS})
+  set(${MODULE}ALIBS)
+#RS  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}-par-all)
+  add_custom_target(test-${MODULE}-par-all)
+  add_custom_target(${MODULE}-all-static)
+  add_dependencies(alilibs-static "${MODULE}-static")
+  add_subdirectory(${MODULE})
+  
+#NY  set(dir "${CMAKE_SOURCE_DIR}/${MODULE}")
+#NY  if (EXISTS "${dir}")
+#NY      file(GLOB CFILES_MOD ${dir}/*.C)
+#NY      list(LENGTH CFILES_MOD len)
+#NY      if (${len} GREATER 0)
+#NY        list(APPEND CFILES_LIST "${CFILES_MOD}")
+#NY      endif (${len} GREATER 0)
+#NY  endif(EXISTS "${dir}")
+endforeach(MODULE)
+
+#NY foreach(cfile ${CFILES_LIST})
+#NY     add_custom_command(TARGET htmldoc
+#NY                   PRE_BUILD
+#NY                   COMMAND cd html && 
+#NY                           aliroot -b -q \"mkhtml.C(\"${cfile}\")\" > /dev/null
+#NY                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+#NY endforeach(cfile)
+
+if(DATE_FOUND)
+  include (CMakeDA)
+endif(DATE_FOUND)
+
+if(RULECHECKER_FOUND)
+    add_custom_target(factfile DEPENDS ${FACTFILE})
+    add_custom_command( OUTPUT ${FACTFILE}
+                        COMMAND ${CMAKE_COMMAND} -E echo "Re-generating factfile"
+                        COMMAND ${JAVA_RUNTIME}  -Xmx1024M -jar ${FACTEXTRACTOR_JAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}                   
+                       DEPENDS check-hxml ${CMAKE_BINARY_DIR}/check-hxml-touchfile ${_factfile_deps} 
+                        WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+endif(RULECHECKER_FOUND)
+
+#--------------------------------------------------------------------------------#
+# Additional Targets                                                             #
+#--------------------------------------------------------------------------------#
+
+# AliMdc RPM
+# ------------------------------
+
+execute_process(
+COMMAND root-config --libdir 
+OUTPUT_VARIABLE ROOTALIBDIR)
+string(REPLACE "\n" "" ROOTALIBDIR ${ROOTALIBDIR}) 
+
+execute_process(
+COMMAND root-config --arch 
+OUTPUT_VARIABLE ARCHITECTURE)
+
+
+set(AEXT a)
+set(LIBPATH ${CMAKE_BINARY_DIR}/lib/tgt_${ALICE_TARGET})
+set(BINPATH ${CMAKE_BINARY_DIR}/bin/tgt_${ALICE_TARGET})
+set(EXPORTDIR ${ALICE_ROOT}/include)
+#set(BINLIBDIRS -L${ALICE_ROOT}/${LIBPATH})
+set(RAWDIRO ${CMAKE_BINARY_DIR}/RAW)
+set(ALIMDCSPECFILE ${RAWDIRO}/alimdc.spec)
+set(RAWDatabaseALIB ${LIBPATH}/libRAWDatabase.${AEXT})
+set(ESDALIB ${LIBPATH}/libESD.${AEXT})
+set(STEERBaseALIB ${LIBPATH}/libSTEERBase.${AEXT})
+set(MDCALIB ${LIBPATH}/libMDC.${AEXT})
+set(MODDIRO RAW/tgt_${ALICE_TARGET})
+
+
+if( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
+set(ALIMDCARCHDIR x86_64)
+elseif( ${ARCHITECTURE} MATCHES "linux" )
+set(ALIMDCARCHDIR i386)
+elseif( ${ARCHITECTURE} MATCHES "linuxia64gcc" )
+set(ALIMDCARCHDIR ia64)
+elseif(NOT DEFINED ${ARCHITECTURE})
+message("alimdc-rpm: Unknown architecture" )
+else( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
+message("alimdc-rpm: Unknown architecture" )
+endif( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
+
+
+# Module version will be written in the generated header
+configure_file ("RAW/alimdc.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/RAW/alimdc.spec" @ONLY)
+
+add_custom_target( alimdc-rpm
+DEPENDS alimdc-static
+)
+
+add_custom_command(
+TARGET alimdc-rpm
+POST_BUILD 
+COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root
+COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
+COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/include
+COMMAND cp ${ALICE_ROOT}/RAW/mdc.h ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/include
+COMMAND cp ${LIBPATH}/libAliMDC.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
+COMMAND cp ${ROOTALIBDIR}/libRoot.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
+COMMAND cp ${ROOTALIBDIR}/liblzma.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
+COMMAND cp ${ROOTALIBDIR}/libpcre.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
+COMMAND cp ${ROOTALIBDIR}/libfreetype.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
+COMMAND cp ${ROOTALIBDIR}/libpcre.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
+COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/RPMS
+COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/RPMS/${ALIMDCARCHDIR}/
+COMMAND rpmbuild --verbose --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}" --define "%buildroot ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root" -bb ${ALIMDCSPECFILE} 
+COMMAND cp -p ${CMAKE_CURRENT_BINARY_DIR}/RPMS/${ALIMDCARCHDIR}/alimdc-*.rpm .
+COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root
+COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/RPMS
+COMMAND echo "***** alimdc RPM created and put in ${CMAKE_BINARY_DIR} folder *****"
+)
+
+add_custom_command(
+TARGET ${RAWDIRO}
+COMMAND mkdir-p ${RAWDIRO}
 )
 
-# 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})
-String(REPLACE "/" "\\\\/"
-  ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
-
-# Additional targets
-Add_Custom_Target(check-all COMMENT "Checking coding conventions")
-
-# Configure special include file
-# Only if there is  a change in the file
-If(UNIX)
-  Set(_in ${CMAKE_CURRENT_SOURCE_DIR}/STEER/ARVersion.h.in)
-  Set(_out ${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h)
-  If(NOT EXISTS ${_out})
-    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)
-  Else(NOT EXISTS ${_out})
-    FILE(READ "${_out}" contents)
-    STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
-    STRING(REGEX REPLACE "\n" ";" contents "${contents}")
-    Foreach(line ${contents})
-      If(line MATCHES "^.*ALIROOT_SVN_REVISION.*$")
-        STRING(REGEX REPLACE "^.*ALIROOT_SVN_REVISION[ ](.*)$" "\\1" _result_svn_rev "${line}")
-      EndIf(line MATCHES "^.*ALIROOT_SVN_REVISION.*$")
-      If(line MATCHES "^.*ALIROOT_SVN_BRANCH.*$")
-        STRING(REGEX REPLACE "^.*ALIROOT_SVN_BRANCH[ ]\"(.*)\"$" "\\1" _result_svn_branch "${line}")
-      EndIf(line MATCHES "^.*ALIROOT_SVN_BRANCH.*$")
-      If(line MATCHES "^.*ALIROOT_VERSION.*$")
-        STRING(REGEX REPLACE "^.*ALIROOT_VERSION[ ](.*)$" "\\1" _result_aliroot_version "${line}")
-      EndIf(line MATCHES "^.*ALIROOT_VERSION.*$")
-    EndForeach(line ${contents})
-    If(_result_aliroot_version STREQUAL ${ALIROOT_VERSION} AND _result_svn_rev STREQUAL ${ALIROOT_SVN_REVISION} AND _result_svn_branch STREQUAL ${ALIROOT_SVN_BRANCH})
-#      MESSAGE("VERSION: ${_result_aliroot_version}")
-#      MESSAGE("VERSION: ${ALIROOT_VERSION}")
-#      MESSAGE("REVISION: ${_result_svn_rev}")
-#      MESSAGE("REVISION: ${ALIROOT_SVN_REVISION}")
-#      MESSAGE("BRANCH: ${_result_svn_branch}")
-#      MESSAGE("BRANCH: ${ALIROOT_SVN_BRANCH}")
-    Else(_result_aliroot_version STREQUAL ${ALIROOT_VERSION} AND _result_svn_rev STREQUAL ${ALIROOT_SVN_REVISION} AND _result_svn_branch STREQUAL ${ALIROOT_SVN_BRANCH})
-    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(_result_aliroot_version STREQUAL ${ALIROOT_VERSION} AND _result_svn_rev STREQUAL ${ALIROOT_SVN_REVISION} AND _result_svn_branch STREQUAL ${ALIROOT_SVN_BRANCH})
-  EndIf(NOT EXISTS ${_out})
-
-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(EPOS) 
-Add_subdirectory(ESDCheck) 
-Add_subdirectory(EVE) 
-Add_subdirectory(EVGEN) 
-Add_subdirectory(FASTSIM) 
-Add_subdirectory(FMD)
-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(TRIGGER) 
-Add_subdirectory(TTherminator) 
-Add_subdirectory(TUHKMgen) 
-Add_subdirectory(VZERO) 
-Add_subdirectory(ZDC) 
+
+add_custom_target( alimdc-static
+DEPENDS ${LIBPATH} ${BINPATH} RAW-all-static STEER-all-static )
+
+add_custom_command( 
+TARGET alimdc-static
+POST_BUILD
+COMMAND ar r ${LIBPATH}/alimdccxxo.a ${CMAKE_BINARY_DIR}/RAW/CMakeFiles/alimdc.dir/alimdc_main.cxx.o
+COMMAND rm -rf ${LIBPATH}/libAliMDC.a
+COMMAND ar x ${RAWDatabaseALIB}
+COMMAND ar x ${MDCALIB}
+COMMAND ar x ${ESDALIB}
+COMMAND ar x ${STEERBaseALIB}
+COMMAND ar r ${LIBPATH}/libAliMDC.a *.o
+COMMAND ar t ${RAWDatabaseALIB} | xargs rm 
+COMMAND ar t ${MDCALIB} | xargs rm 
+COMMAND ar t ${ESDALIB} | xargs rm 
+COMMAND ar t ${STEERBaseALIB} | xargs rm 
+COMMAND ${CMAKE_CXX_COMPILER} ${LDFLAGS} -o ${BINPATH}/alimdca ${LIBPATH}/alimdccxxo.a ${LIBPATH}/libAliMDC.a ${ROOTALIBDIR}/libRoot.a ${ROOTALIBDIR}/libfreetype.a ${ROOTALIBDIR}/libpcre.a ${ROOTALIBDIR}/liblzma.a -pthread -lssl -ldl -lz
+COMMAND @echo "Target alimdc-static made"
+)
+
+add_custom_command(
+TARGET ${LIBPATH}
+COMMAND mkdir -p ${LIBPATH}
+)
+
+
+#include (MakefileDA) 
+include (InstallRequiredSystemLibraries)
+include (CPack)
+
+# Install data
+# ------------------------------
+install ( DIRECTORY data 
+          DESTINATION . )
+install ( DIRECTORY OCDB 
+         DESTINATION . 
+         PATTERN ".svn" EXCLUDE)
+install ( DIRECTORY QAref 
+         DESTINATION . 
+         PATTERN ".svn" EXCLUDE)
+install ( DIRECTORY GRP 
+         DESTINATION . 
+         PATTERN ".svn" EXCLUDE)
+
+#
+# EOF
 #
-Add_subdirectory(ALIROOT)