Back to home page

EIC code displayed by LXR

 
 

    


Warning, /estarlight/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 ###########################################################################
0002 #
0003 #    Copyright 2010
0004 #
0005 #    This file is part of Starlight.
0006 #
0007 #    Starlight is free software: you can redistribute it and/or modify
0008 #    it under the terms of the GNU General Public License as published by
0009 #    the Free Software Foundation, either version 3 of the License, or
0010 #    (at your option) any later version.
0011 #         
0012 #    Starlight is distributed in the hope that it will be useful,
0013 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0015 #    GNU General Public License for more details.
0016 #         
0017 #    You should have received a copy of the GNU General Public License
0018 #    along with Starlight. If not, see <http://www.gnu.org/licenses/>.
0019 #
0020 ###########################################################################
0021 #
0022 # File and Version Information:
0023 # $Rev:: 247                         $: revision of last commit
0024 # $Author:: butter                   $: author of last commit
0025 # $Date:: 2016-03-05 00:59:24 +0000 #$: date of last commit
0026 #
0027 # Description:
0028 #      Starlight build file
0029 #
0030 #
0031 ###########################################################################
0032 
0033 
0034 # check if cmake has the required version
0035 cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
0036 
0037 # set verbosity
0038 set(CMAKE_VERBOSE_MAKEFILE 0)  # if set to 1 compile and link commands are displayed during build
0039 # the same effect can be achieved by calling 'make VERBOSE=1'
0040 
0041 
0042 # The version number. 9999 indicates trunk
0043 set (Starlight_VERSION_MAJOR 9999) 
0044 set (Starlight_VERSION_MINOR 1)
0045 set (Starlight_VERSION_MINOR_MINOR 0)
0046 
0047 # define project
0048 project(starlight)
0049 #find_package (Threads)
0050 
0051 # load some common cmake macros
0052 # set path, where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
0053 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules")
0054 message(STATUS "Using cmake module path '${CMAKE_MODULE_PATH}'")
0055 include(CommonMacros)
0056 
0057 
0058 # force out-of-source builds.
0059 enforce_out_of_source_build()
0060 
0061 
0062 # warn user if system is not UNIX
0063 if(NOT UNIX)
0064   message(FATAL_ERROR "This is an unsupported system.")
0065 endif()
0066 message(STATUS "Detected host system '${CMAKE_HOST_SYSTEM_NAME}' version '${CMAKE_HOST_SYSTEM_VERSION}' architecture '${CMAKE_HOST_SYSTEM_PROCESSOR}'")
0067 message(STATUS "Compiling for system '${CMAKE_SYSTEM_NAME}' version '${CMAKE_SYSTEM_VERSION}' architecture '${CMAKE_SYSTEM_PROCESSOR}'")
0068 
0069 option (CPP11 "Enable compilation with C++11 features" ON) 
0070 
0071 # define build types
0072 # set a default build type for single-configuration CMake generators, if no build type is set.
0073 set(CMAKE_BUILD_TYPE Debug)
0074 if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
0075   message(STATUS "No build type was specified. Setting build type to 'Release'.")
0076   set(CMAKE_BUILD_TYPE Release)
0077 endif()
0078 
0079 # Set the C++ standard
0080 set(CMAKE_CXX_STANDARD 11)
0081 set(CMAKE_CXX_STANDARD_REQUIRED True)
0082 
0083 # common compiler flags
0084 if (CMAKE_COMPILER_IS_GNUCC)
0085   execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
0086   message(STATUS "GCC_VERSTION")
0087   message(STATUS  ${GCC_VERSION})
0088   if (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
0089     message(STATUS "GCC_VERSION>=4.6")
0090     if(CPP11)
0091       set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-parameter -std=c++11")
0092       message(STATUS "Enabling usage of C++11 features")
0093     else()
0094       set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-parameter")
0095     endif()
0096   else()
0097     message(STATUS "GCC_VERSION<4.6")
0098       set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-parameter")
0099     if(CPP11)
0100       message(WARNING "C++11 features not supported for your compiler")
0101     endif()
0102   endif()
0103 else()
0104   message(STATUS "Not GCC")
0105   set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror")
0106   if(CPP11)
0107     set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -std=c++11")
0108     # message(WARNING "C++11 features not supported for your compiler")
0109     message(WARNING "Trying to enable C++11 features with '-std=c++11'")
0110   endif()
0111 endif()
0112 # flags for specific build types
0113 set(CMAKE_CXX_FLAGS_DEBUG "-g")
0114 set(CMAKE_CXX_FLAGS_RELEASE "-O3")
0115 set(CMAKE_CXX_LDFLAGS_DEBUG "-g")
0116 # report global build settings
0117 message(STATUS "Using CXX compiler '${CMAKE_CXX_COMPILER}'")
0118 message(STATUS "Using CXX general compiler flags '${CMAKE_CXX_FLAGS}'")
0119 foreach(_BUILD_TYPE "DEBUG" "MINSIZEREL" "RELEASE" "RELWITHDEBINFO")
0120   message(STATUS "Using CXX compiler flags '${CMAKE_CXX_FLAGS_${_BUILD_TYPE}}' for build type ${_BUILD_TYPE}")
0121 endforeach()
0122 message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'")
0123 
0124 
0125 # redirect output files
0126 #set(LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/lib")
0127 message(STATUS "Using library output path '${LIBRARY_OUTPUT_PATH}'")
0128 #set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
0129 message(STATUS "Using executable output path '${EXECUTABLE_OUTPUT_PATH}'")
0130 
0131 
0132 # make CMAKE_SOURCE_DIR accessible in source code via predefined macro CMAKE_SOURCE_DIR
0133 if(CMAKE_SOURCE_DIR)
0134   add_definitions(-D'CMAKE_SOURCE_DIR=\"${CMAKE_SOURCE_DIR}\"')
0135 else()
0136   add_definitions(-D'CMAKE_SOURCE_DIR=\"\"')
0137 endif()
0138 
0139 
0140 # make SVN version string accessible in source code via predefined macro SVN_VERSION
0141 find_package(Subversion)
0142 if(Subversion_FOUND)
0143   # unfortunately CMAKE only parses 'svn info'
0144   find_program(SVNVERSION_EXECUTABLE
0145     svnversion
0146                 )
0147   if(NOT SVNVERSION_EXECUTABLE)
0148     message(STATUS "Could not find subversion command 'svnversion'. Repository version unknown.")
0149   else()
0150     execute_process(
0151       COMMAND ${SVNVERSION_EXECUTABLE} "${CMAKE_SOURCE_DIR}"
0152       OUTPUT_VARIABLE SVN_VERSION
0153       RESULT_VARIABLE _SVNVERSION_RETURN
0154       OUTPUT_STRIP_TRAILING_WHITESPACE)
0155     if(NOT ${_SVNVERSION_RETURN})
0156       message(STATUS "Subversion repository revision is '${SVN_VERSION}'")
0157     else()
0158       message(STATUS "Error running 'svnversion'. Repository version unknown.")
0159       set(SVN_VERSION "")
0160     endif()
0161   endif()
0162 else()
0163   message(STATUS "Could not find subversion installation. Repository version unknown.")
0164 endif()
0165 if(SVN_VERSION)
0166   add_definitions(-D'SVN_VERSION=\"${SVN_VERSION}\"')
0167 else()
0168   add_definitions(-D'SVN_VERSION=\"\"')
0169 endif()
0170 
0171 
0172 # setup doxygen
0173 find_package(Doxygen)
0174 if(NOT DOXYGEN_FOUND)
0175   message(WARNING "Cannot find Doxygen. No HTML documentation will be generated.")
0176 else()
0177   set(DOXYGEN_TARGET  "doxygen")
0178   set(DOXYGEN_DOC_DIR "${CMAKE_SOURCE_DIR}/doxygen")
0179   set(DOXYGEN_CONF    "${CMAKE_SOURCE_DIR}/starlightDoxyfile.conf")
0180   message(STATUS "Run 'make ${DOXYGEN_TARGET}' to create Doxygen documentation files in '${DOXYGEN_DOC_DIR}'")
0181   add_custom_target(${DOXYGEN_TARGET}
0182     COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONF}
0183     DEPENDS ${DOXYGEN_CONF}
0184     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
0185                 )
0186 endif()
0187 
0188 option (ENABLE_HEPMC3  "Enable compilation against hepmc3 (necessary for hepmc3 output)" OFF) 
0189 if(ENABLE_HEPMC3)
0190   find_package(HepMC3 HINTS ${HepMC3_DIR} ${HepMC3} )
0191   if(HepMC3_FOUND)
0192     message ( "-- HepMC3 library found at ${HEPMC3_LIB} --> Adding HepMC sources and headers" )
0193     set(optionalLibs ${optionalLibs} ${HEPMC3_LIB})
0194     option(ENABLE_HEPMC3  "Should we use the HepMC3 library" ON) 
0195   else()
0196     message ( WARNING "Hepmc3 not found.")
0197     option(ENABLE_HEPMC3  "Should we use the HepMC3 library" OFF) 
0198   endif()
0199 endif()
0200 
0201 # setup Pythia 8
0202 option (ENABLE_PYTHIA  "Enable compilation against pythia (necessary for certain processes)" OFF) 
0203 if(ENABLE_PYTHIA)
0204   find_package(Pythia8)
0205   if(PYTHIA8_FOUND)
0206     set(optionalLibs ${optionalLibs} ${PYTHIA8_LIBRARY})
0207 #    find_package(LHAPDF REQUIRED) # implemented for dummy version in Pythia8
0208 #    set(optionalLibs ${optionalLibs} ${LHAPDF_LIBRARIES})#liblhapdfdummy
0209 #    removed from v8.2, if you want to add your own lhapdf set, uncomment
0210 #    find_package + set  - jb 05192015
0211     option(ENABLE_PYTHIA  "Should we use the Pythia8 library" ON) 
0212   else() 
0213     option(ENABLE_PYTHIA  "Should we use the Pythia8 library" OFF) 
0214   endif()
0215 endif()
0216 
0217 # setup Pythia 6
0218 option (ENABLE_PYTHIA6  "Enable compilation against pythia 6 (necessary for certain processes)" OFF) 
0219 if(ENABLE_PYTHIA6)
0220    find_package(Pythia6 REQUIRED)
0221    if(PYTHIA6_FOUND)
0222       set(optionalLibs ${optionalLibs} ${PYTHIA6_LIBRARY})
0223       option (ENABLE_PYTHIA6  "Enable compilation against pythia 6 (necessary for certain processes)" ON) 
0224       include_directories(pythia6)
0225    else(PYTHIA6_FOUND) 
0226       option (ENABLE_PYTHIA6  "Enable compilation against pythia 6 (necessary for certain processes)" OFF) 
0227    endif(PYTHIA6_FOUND)
0228 endif()
0229 
0230 # set include directories
0231 set(INCLUDE_DIRECTORIES
0232         ${CMAKE_SOURCE_DIR}/include
0233         ${PROJECT_BINARY_DIR}
0234         ${PYTHIA8_INCLUDE_DIR}#uncommented 05192015
0235         )
0236 include_directories(${INCLUDE_DIRECTORIES})
0237 
0238 # Set our source files, include the generated dictionary
0239 set(SOURCES
0240   src/bessel.cpp
0241   src/beam.cpp
0242   src/inputParameters.cpp
0243   src/beambeamsystem.cpp
0244   src/starlightparticle.cpp
0245   src/gammaaluminosity.cpp
0246   src/randomgenerator.cpp
0247   src/nucleus.cpp
0248   src/eventchannel.cpp
0249   src/gammaavm.cpp
0250   src/gammagammasingle.cpp
0251   src/photonNucleusCrossSection.cpp
0252   src/wideResonanceCrossSection.cpp
0253   src/narrowResonanceCrossSection.cpp
0254   src/readinluminosity.cpp
0255   src/twophotonluminosity.cpp
0256   src/vector3.cpp
0257   src/lorentzvector.cpp
0258   src/filewriter.cpp
0259   src/eventfilewriter.cpp
0260   src/starlightparticlecodes.cpp
0261   src/nBodyPhaseSpaceGen.cpp
0262   src/inputParser.cpp
0263   src/incoherentPhotonNucleusLuminosity.cpp
0264   src/incoherentVMCrossSection.cpp
0265 # eSTARlight
0266   src/eXevent.cpp
0267   src/gammaeluminosity.cpp      
0268   src/e_wideResonanceCrossSection.cpp
0269   src/e_narrowResonanceCrossSection.cpp
0270   src/e_starlight.cpp
0271   src/e_starlightStandalone.cpp
0272   )
0273 
0274 if (ENABLE_HEPMC3)
0275   set (SOURCES
0276                 ${SOURCES}
0277                 src/hepmc3writer.cpp
0278                 )
0279   include_directories(${HEPMC3_INCLUDE_DIR})
0280   add_definitions( -DHEPMC3_ON )
0281 endif()
0282 if(ENABLE_PYTHIA) 
0283   set (SOURCES
0284                 ${SOURCES}
0285                 #src/PythiaStarlight.cpp
0286                 src/pythiadecayer.cpp
0287                 )
0288   include_directories(${PYTHIA8_INCLUDE_DIR})
0289 endif()
0290 if(ENABLE_PYTHIA6)
0291   set (SOURCES 
0292                 ${SOURCES}
0293                 src/starlightpythia.cpp
0294                 src/spectrum.cpp
0295                 src/spectrumprotonnucleus.cpp
0296                 )
0297 endif()
0298 
0299 # add Starlight library to the build system
0300 set(THIS_LIB "Starlib")
0301 add_library(${THIS_LIB} STATIC ${SOURCES})
0302 #make_shared_library("${THIS_LIB}" "${SOURCES}"
0303 #       "${PYTHIA8_LIBRARY}"
0304 #       "${LHAPDF_LIBRARIES}"
0305 #)
0306 
0307 if(ENABLE_PYTHIA6)
0308   enable_language(Fortran)
0309 endif()
0310 
0311 # add starlight executable to the build system
0312 add_executable(e_starlight src/e_main.cpp)
0313 target_link_libraries(e_starlight Starlib ${optionalLibs})# ${CMAKE_THREAD_LIBS_INIT}) 
0314 
0315 configure_file (
0316   "${PROJECT_SOURCE_DIR}/starlightconfig.h.in"
0317   "${PROJECT_BINARY_DIR}/starlightconfig.h"
0318   )
0319 # Erase xsec values in case changes in code affects the xsec, executed during make process
0320 add_custom_command (TARGET Starlib POST_BUILD COMMAND touch ARGS slight.txt)
0321 add_custom_command (TARGET Starlib POST_BUILD COMMAND cp ARGS slight.txt slight.txt.bak)
0322 add_custom_command (TARGET Starlib POST_BUILD COMMAND echo ARGS '' > slight.txt )
0323 
0324 # Installation of targets
0325 install(TARGETS e_starlight ${THIS_LIB}
0326   LIBRARY DESTINATION lib
0327   ARCHIVE DESTINATION lib
0328   RUNTIME DESTINATION bin
0329   INCLUDES DESTINATION include
0330 )
0331 
0332 message(STATUS "Cmake did not find any errors. run 'make' to build the project.")
0333 message(STATUS "On multi-core machines 'make -j#', where # is the number of parallel jobs, can speedup compilation considerably.")