From 1dbe107618c6735b5ca7498a8df939ab6155d5d9 Mon Sep 17 00:00:00 2001 From: agrigora Date: Mon, 20 Oct 2014 14:51:26 +0200 Subject: [PATCH] LHAPDF + Using ROOT fortran --- CMakeLists.txt | 35 +++++++---- ITS/ITSbase/CMakeLists.txt | 2 +- LHAPDF/CMakeLists.txt | 126 ++++++++++++++++++++++++++++++++++--- cmake/FindROOT.cmake | 10 ++- 4 files changed, 152 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e42f477150..5a1cbb0d382 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,15 +21,6 @@ cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) project(AliRoot CXX C) -# If no Fortran, i.e on Windows -include(CheckLanguage) -check_language(Fortran) -if(CMAKE_Fortran_COMPILER) - enable_language(Fortran OPTIONAL) -else() - message("No Fortran support. Disabling LHAPDF, PHYTIA6, MICROCERN") -endif() - # Path to additonal modules set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -52,6 +43,26 @@ else() message(FATAL_ERROR "ROOT installation not found!\nPlease point to the ROOT installation using -DROOTSYS=ROOT_INSTALL_DIR") endif(ROOTSYS) +# If no Fortran, i.e on Windows +# We need to specify ROOT fortran +# (f95 comes before gfortran in default module) +include(CheckLanguage) + +if(ROOT_FORTRAN) + message(STATUS "Using the Fortran compiler defined by ROOT configuration: ${ROOT_FORTRAN}") + set(CMAKE_Fortran_COMPILER ${ROOT_FORTRAN}) +else() + message(STATUS "Using default system Fortran compiler") +endif(ROOT_FORTRAN) + +check_language(Fortran) +if(CMAKE_Fortran_COMPILER) + enable_language(Fortran OPTIONAL) +else() + message("No Fortran support. Disabling LHAPDF, PHYTIA6, MICROCERN") +endif() + + # DATE find_package(DATE) @@ -94,11 +105,11 @@ add_subdirectory(TRIGGER) add_subdirectory(BCM) add_subdirectory(CORRFW) add_subdirectory(FASTSIM) -#if(CMAKE_Fortran_COMPILER_WORKS) -# add_subdirectory (LHAPDF) +if(CMAKE_Fortran_COMPILER) + add_subdirectory (LHAPDF) # add_subdirectory (PYTHIA6) # add_subdirectory (MICROCERN) -#endif(CMAKE_Fortran_COMPILER_WORKS) +endif(CMAKE_Fortran_COMPILER) #add_subdirectory (EVGEN) #add_subdirectory (TUHKMgen) #add_subdirectory (TTherminator) diff --git a/ITS/ITSbase/CMakeLists.txt b/ITS/ITSbase/CMakeLists.txt index f9f4d6a0b71..2ec34bfdce0 100644 --- a/ITS/ITSbase/CMakeLists.txt +++ b/ITS/ITSbase/CMakeLists.txt @@ -20,7 +20,7 @@ set(MODULE ITSbase) include_directories(${CMAKE_SOURCE_DIR}/ITS/${MODULE}) # Additional include folders in alphabetical order except ROOT -include_directories(${ROOT_INCLUDE_DIRS} +include_directories(${ROOT_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/ITS/ITSrec ${CMAKE_SOURCE_DIR}/ITS/ITSsim ${CMAKE_SOURCE_DIR}/RAW/RAWDatabase diff --git a/LHAPDF/CMakeLists.txt b/LHAPDF/CMakeLists.txt index 1134d5c54a0..91aca726ccd 100644 --- a/LHAPDF/CMakeLists.txt +++ b/LHAPDF/CMakeLists.txt @@ -1,10 +1,122 @@ -# AliRoot Build System CMakeLists for LHAPDF -# -# Author: Johny Jose m(johny.jose@cern.ch) -# Port of previous Makefile build to cmake +# ************************************************************************** +# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. * +# * * +# * Author: The ALICE Off-line Project. * +# * Contributors are mentioned in the code where appropriate. * +# * * +# * Permission to use, copy, modify and distribute this software and its * +# * documentation strictly for non-commercial purposes is hereby granted * +# * without fee, provided that the above copyright notice appears in all * +# * copies and that both the copyright notice and this permission notice * +# * appear in the supporting documentation. The authors make no claims * +# * about the suitability of this software for any purpose. It is * +# * provided "as is" without express or implied warranty. * +# ************************************************************************** -cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) +# Module +set(MODULE lhapdf) -file(GLOB PACKAGES CMake*.pkg) +# Module include folder +include_directories(${CMAKE_SOURCE_DIR}/LHAPDF) -ALICE_BuildModule() +# Additional include folders in alphabetical order except ROOT +include_directories(${ROOT_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/LHAPDF/lhapdf5.5.1 + ${CMAKE_SOURCE_DIR}/LHAPDF/lhapdf5.5.1/include + ${CMAKE_SOURCE_DIR}/LHAPDF/lhapdf5.5.1/src + ) + +# Sources in alphabetical order +set(SRCS + AliStructFuncType.cxx + lhapdf5.5.1/src/version.cxx + lhapdf5.5.1/src/getdatapath.cxx + ) + +# Headers +set(HDRS + AliStructFuncType.h + ) + +# C sources +set(CSRCS + lhapdf5.5.1/src/binreloc.c + ) + +# Fortran sources +set(FSRCS + lhapdf5.5.1/src/alphas.f + lhapdf5.5.1/src/commoninit.f + lhapdf5.5.1/src/description.f + lhapdf5.5.1/src/eks98.f + lhapdf5.5.1/src/eksarp.f + lhapdf5.5.1/src/eps08.f + lhapdf5.5.1/src/eps09.f + lhapdf5.5.1/src/EVLCTEQ.f + lhapdf5.5.1/src/evolution.f + lhapdf5.5.1/src/inputPDF.f + lhapdf5.5.1/src/LHpdflib.F + lhapdf5.5.1/src/parameter.f + lhapdf5.5.1/src/QCDNUM.f + lhapdf5.5.1/src/QCDparams.f + lhapdf5.5.1/src/Sqcdnum.f + lhapdf5.5.1/src/wrapa02.f + lhapdf5.5.1/src/wrapa02m.f + lhapdf5.5.1/src/wrapabfkwpi.f + lhapdf5.5.1/src/wrapacfgpg.f + lhapdf5.5.1/src/wrapcteq5.f + lhapdf5.5.1/src/wrapcteq6.f + lhapdf5.5.1/src/wrapcteq6lg.f + lhapdf5.5.1/src/wrapdgg.f + lhapdf5.5.1/src/wrapdog.f + lhapdf5.5.1/src/wrapEVLCTEQ.f + lhapdf5.5.1/src/wrapevolve.f + lhapdf5.5.1/src/wrapgrv.f + lhapdf5.5.1/src/wrapgrvg.f + lhapdf5.5.1/src/wrapgrvpi.f + lhapdf5.5.1/src/wrapgsg96.f + lhapdf5.5.1/src/wrapgsg.f + lhapdf5.5.1/src/wraph1.f + lhapdf5.5.1/src/wraplacg.f + lhapdf5.5.1/src/wrapowpi.f + lhapdf5.5.1/src/wrapmrst.f + lhapdf5.5.1/src/wrapQCDNUM3.f + lhapdf5.5.1/src/wrapQCDNUM4.f + lhapdf5.5.1/src/wrapQCDNUM.f + lhapdf5.5.1/src/wrapsasg.f + lhapdf5.5.1/src/wrapsmrspi.f + lhapdf5.5.1/src/wrapwhitg.f + lhapdf5.5.1/src/wrapzeus.f + lhapdf5.5.1/src/lhaglue.f + lhapdf5.5.1/src/wrapUSER.f + ) + +# Generate the dictionary +# It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument +get_directory_property(incdirs INCLUDE_DIRECTORIES) +generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}") + +# Generate the ROOT map +# Dependecies +set(LIBDEPS Core) +generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h") + +# Add a library to the project using the specified source files +add_library(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx ${CSRCS} ${FSRCS}) + +# Additional compilation flags +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-ansi") +set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS "-O -g" Fortran_FORMAT FREE ) +add_definitions(-DDEFAULTPREFIXPATH="NONE" -DDEFAULTLHAPATH="${CMAKE_SOURCE_DIR}/LHAPDF/PDFsets") + +# System dependent: Modify the way the library is build +if(${CMAKE_SYSTEM} MATCHES Darwin) + set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") +endif(${CMAKE_SYSTEM} MATCHES Darwin) + +# Installation +install(TARGETS ${MODULE} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib) +install(FILES ${HDRS} DESTINATION include) +install(DIRECTORY PDFsets DESTINATION LHAPDF) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 8a665319e7a..1be750d9c46 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -30,7 +30,7 @@ # - ROOT_INCLUDE_DIRS - full path to ROOT include folder # - ROOT_HASALIEN - ROOT was built with AliEn support # - ROOT_HASXML - ROOT was built with XML support - +# - ROOT_FORTRAN - fortran compiler if(ROOTSYS) message(STATUS "Checking for a proper ROOT installation in ${ROOTSYS}.") @@ -145,6 +145,14 @@ if(ROOTSYS) message(FATAL_ERROR "Error checking if ROOT was build with xml support: ${error}") endif(error) string(STRIP ${ROOT_HASXML} ROOT_HASXML) + + + # Checking for xml support + execute_process(COMMAND ${ROOT_CONFIG} --f77 OUTPUT_VARIABLE ROOT_FORTRAN ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(error) + message(FATAL_ERROR "Error checking ROOT fortran compiler: ${error}") + endif(error) + string(STRIP ${ROOT_FORTRAN} ROOT_FORTRAN) set(ROOT_FOUND TRUE) else() -- 2.39.3