Warning, /estarlight/utils/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
0038 # set verbosity
0039 set(CMAKE_VERBOSE_MAKEFILE 0) # if set to 1 compile and link commands are displayed during build
0040 # the same effect can be achieved by calling 'make VERBOSE=1'
0041
0042
0043 # The version number. 9999 indicates trunk
0044 set (Starlight_VERSION_MAJOR 9999)
0045 set (Starlight_VERSION_MINOR 1)
0046 set (Starlight_VERSION_MINOR_MINOR 0)
0047
0048 # define project
0049 project(starlight)
0050 #find_package (Threads)
0051
0052 # load some common cmake macros
0053 # set path, where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
0054 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules")
0055 message(STATUS "Using cmake module path '${CMAKE_MODULE_PATH}'")
0056 include(CommonMacros)
0057
0058
0059 # force out-of-source builds.
0060 enforce_out_of_source_build()
0061
0062
0063 # warn user if system is not UNIX
0064 if(NOT UNIX)
0065 message(FATAL_ERROR "This is an unsupported system.")
0066 endif()
0067 message(STATUS "Detected host system '${CMAKE_HOST_SYSTEM_NAME}' version '${CMAKE_HOST_SYSTEM_VERSION}' architecture '${CMAKE_HOST_SYSTEM_PROCESSOR}'")
0068 message(STATUS "Compiling for system '${CMAKE_SYSTEM_NAME}' version '${CMAKE_SYSTEM_VERSION}' architecture '${CMAKE_SYSTEM_PROCESSOR}'")
0069
0070 option (CPP11 "Enable compilation with C++11 features" OFF)
0071
0072 # define build types
0073 # set a default build type for single-configuration CMake generators, if no build type is set.
0074 set(CMAKE_BUILD_TYPE Debug)
0075 if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
0076 message(STATUS "No build type was specified. Setting build type to 'Release'.")
0077 set(CMAKE_BUILD_TYPE Release)
0078 endif()
0079 # common compiler flags
0080 if (CMAKE_COMPILER_IS_GNUCC)
0081 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
0082 message(STATUS "GCC_VERSTION")
0083 message(STATUS ${GCC_VERSION})
0084 if (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
0085 message(STATUS "GCC_VERSION>=4.6")
0086 if(CPP11)
0087 set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-parameter -std=c++11")
0088 message(STATUS "Enabling usage of C++11 features")
0089 else()
0090 set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-parameter")
0091 endif()
0092 else()
0093 message(STATUS "GCC_VERSION<4.6")
0094 set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-parameter")
0095 if(CPP11)
0096 message(WARNING "C++11 feautures not supported for your compiler")
0097 endif()
0098 endif()
0099 else()
0100 message(STATUS "Not GCC")
0101 set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror")
0102 if(CPP11)
0103 message(WARNING "C++11 feautures not supported for your compiler")
0104 endif()
0105 endif()
0106 # flags for specific build types
0107 set(CMAKE_CXX_FLAGS_DEBUG "-g")
0108 set(CMAKE_CXX_FLAGS_RELEASE "-O3")
0109 set(CMAKE_CXX_LDFLAGS_DEBUG "-g")
0110 # report global build settings
0111 message(STATUS "Using CXX compiler '${CMAKE_CXX_COMPILER}'")
0112 message(STATUS "Using CXX general compiler flags '${CMAKE_CXX_FLAGS}'")
0113 foreach(_BUILD_TYPE "DEBUG" "MINSIZEREL" "RELEASE" "RELWITHDEBINFO")
0114 message(STATUS "Using CXX compiler flags '${CMAKE_CXX_FLAGS_${_BUILD_TYPE}}' for build type ${_BUILD_TYPE}")
0115 endforeach()
0116 message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'")
0117
0118
0119 # redirect output files
0120 #set(LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/lib")
0121 message(STATUS "Using library output path '${LIBRARY_OUTPUT_PATH}'")
0122 #set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
0123 message(STATUS "Using executable output path '${EXECUTABLE_OUTPUT_PATH}'")
0124
0125
0126 # make CMAKE_SOURCE_DIR accessible in source code via predefined macro CMAKE_SOURCE_DIR
0127 if(CMAKE_SOURCE_DIR)
0128 add_definitions(-D'CMAKE_SOURCE_DIR=\"${CMAKE_SOURCE_DIR}\"')
0129 else()
0130 add_definitions(-D'CMAKE_SOURCE_DIR=\"\"')
0131 endif()
0132
0133
0134 # make SVN version string accessible in source code via predefined macro SVN_VERSION
0135 find_package(Subversion)
0136 if(Subversion_FOUND)
0137 # unfortunately CMAKE only parses 'svn info'
0138 find_program(SVNVERSION_EXECUTABLE
0139 svnversion
0140 )
0141 if(NOT SVNVERSION_EXECUTABLE)
0142 message(STATUS "Could not find subversion command 'svnversion'. Repository version unknown.")
0143 else()
0144 execute_process(
0145 COMMAND ${SVNVERSION_EXECUTABLE} "${CMAKE_SOURCE_DIR}"
0146 OUTPUT_VARIABLE SVN_VERSION
0147 RESULT_VARIABLE _SVNVERSION_RETURN
0148 OUTPUT_STRIP_TRAILING_WHITESPACE)
0149 if(NOT ${_SVNVERSION_RETURN})
0150 message(STATUS "Subversion repository revision is '${SVN_VERSION}'")
0151 else()
0152 message(STATUS "Error running 'svnversion'. Repository version unknown.")
0153 set(SVN_VERSION "")
0154 endif()
0155 endif()
0156 else()
0157 message(STATUS "Could not find subversion installation. Repository version unknown.")
0158 endif()
0159 if(SVN_VERSION)
0160 add_definitions(-D'SVN_VERSION=\"${SVN_VERSION}\"')
0161 else()
0162 add_definitions(-D'SVN_VERSION=\"\"')
0163 endif()
0164
0165
0166 # setup doxygen
0167 find_package(Doxygen)
0168 if(NOT DOXYGEN_FOUND)
0169 message(WARNING "Cannot find Doxygen. No HTML documentation will be generated.")
0170 else()
0171 set(DOXYGEN_TARGET "doxygen")
0172 set(DOXYGEN_DOC_DIR "${CMAKE_SOURCE_DIR}/doxygen")
0173 set(DOXYGEN_CONF "${CMAKE_SOURCE_DIR}/starlightDoxyfile.conf")
0174 message(STATUS "Run 'make ${DOXYGEN_TARGET}' to create Doxygen documentation files in '${DOXYGEN_DOC_DIR}'")
0175 add_custom_target(${DOXYGEN_TARGET}
0176 COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONF}
0177 DEPENDS ${DOXYGEN_CONF}
0178 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
0179 )
0180 endif()
0181
0182
0183 # setup Pythia 8
0184 option (ENABLE_PYTHIA "Enable compilation against pythia (necessary for certain processes)" OFF)
0185 if(ENABLE_PYTHIA)
0186 find_package(Pythia8)
0187 if(PYTHIA8_FOUND)
0188 set(optionalLibs ${optionalLibs} ${PYTHIA8_LIBRARY})
0189 # find_package(LHAPDF REQUIRED) # implemented for dummy version in Pythia8
0190 # set(optionalLibs ${optionalLibs} ${LHAPDF_LIBRARIES})#liblhapdfdummy
0191 # removed from v8.2, if you want to add your own lhapdf set, uncomment
0192 # find_package + set - jb 05192015
0193 option(ENABLE_PYTHIA "Should we use the Pythia8 library" ON)
0194 else()
0195 option(ENABLE_PYTHIA "Should we use the Pythia8 library" OFF)
0196 endif()
0197 endif()
0198
0199 # setup Pythia 6
0200 option (ENABLE_PYTHIA6 "Enable compilation against pythia 6 (necessary for certain processes)" OFF)
0201 if(ENABLE_PYTHIA6)
0202 find_package(Pythia6 REQUIRED)
0203 if(PYTHIA6_FOUND)
0204 set(optionalLibs ${optionalLibs} ${PYTHIA6_LIBRARY})
0205 option (ENABLE_PYTHIA6 "Enable compilation against pythia 6 (necessary for certain processes)" ON)
0206 include_directories(pythia6)
0207 else(PYTHIA6_FOUND)
0208 option (ENABLE_PYTHIA6 "Enable compilation against pythia 6 (necessary for certain processes)" OFF)
0209 endif(PYTHIA6_FOUND)
0210 endif()
0211
0212 # setup DPMJET
0213 option (ENABLE_DPMJET "Enable compilation against DPMJet" OFF)
0214 if(ENABLE_DPMJET)
0215 find_package(DPMJet REQUIRED)
0216 if(DPMJET_FOUND)
0217 option (ENABLE_DPMJET "Enable compilation against DPMJet" ON)
0218 else(DPMJET_FOUND)
0219 option (ENABLE_DPMJET "Enable compilation against DPMJet" OFF)
0220 endif(DPMJET_FOUND)
0221 endif(ENABLE_DPMJET)
0222
0223
0224 # set include directories
0225 set(INCLUDE_DIRECTORIES
0226 ${CMAKE_SOURCE_DIR}/include
0227 ${PROJECT_BINARY_DIR}
0228 ${PYTHIA8_INCLUDE_DIR}#uncommented 05192015
0229 )
0230 include_directories(${INCLUDE_DIRECTORIES})
0231
0232 # Set our source files, include the generated dictionary
0233 set(SOURCES
0234 src/bessel.cpp
0235 src/beam.cpp
0236 src/inputParameters.cpp
0237 src/beambeamsystem.cpp
0238 src/starlightparticle.cpp
0239 src/gammaaluminosity.cpp
0240 src/randomgenerator.cpp
0241 src/nucleus.cpp
0242 src/eventchannel.cpp
0243 src/gammaavm.cpp
0244 src/gammagammasingle.cpp
0245 src/photonNucleusCrossSection.cpp
0246 src/wideResonanceCrossSection.cpp
0247 src/narrowResonanceCrossSection.cpp
0248 src/readinluminosity.cpp
0249 src/twophotonluminosity.cpp
0250 src/gammagammaleptonpair.cpp
0251 src/starlight.cpp
0252 src/upcevent.cpp
0253 src/vector3.cpp
0254 src/lorentzvector.cpp
0255 src/filewriter.cpp
0256 src/eventfilewriter.cpp
0257 src/starlightparticlecodes.cpp
0258 src/starlightStandalone.cpp
0259 src/nBodyPhaseSpaceGen.cpp
0260 src/inputParser.cpp
0261 src/incoherentPhotonNucleusLuminosity.cpp
0262 src/incoherentVMCrossSection.cpp
0263 # eSTARlight
0264 src/eXevent.cpp
0265 src/gammaeluminosity.cpp
0266 src/e_wideResonanceCrossSection.cpp
0267 src/e_narrowResonanceCrossSection.cpp
0268 src/e_starlight.cpp
0269 src/e_starlightStandalone.cpp
0270 )
0271 if(ENABLE_PYTHIA)
0272 set (SOURCES
0273 ${SOURCES}
0274 #src/PythiaStarlight.cpp
0275 src/pythiadecayer.cpp
0276 )
0277 include_directories(${PYTHIA8_INCLUDE_DIR})
0278 endif()
0279 if(ENABLE_PYTHIA6)
0280 set (SOURCES
0281 ${SOURCES}
0282 src/starlightpythia.cpp
0283 src/spectrum.cpp
0284 src/spectrumprotonnucleus.cpp
0285 )
0286 endif()
0287 if(ENABLE_DPMJET)
0288 set (SOURCES
0289 ${SOURCES}
0290 src/starlightdpmjet.cpp
0291 src/spectrum.cpp
0292 src/spectrumprotonnucleus.cpp
0293 )
0294 endif()
0295
0296 # add Starlight library to the build system
0297 set(THIS_LIB "Starlib")
0298 add_library(${THIS_LIB} STATIC ${SOURCES})
0299 #make_shared_library("${THIS_LIB}" "${SOURCES}"
0300 # "${PYTHIA8_LIBRARY}"
0301 # "${LHAPDF_LIBRARIES}"
0302 #)
0303
0304 if(ENABLE_DPMJET)
0305 enable_language(Fortran)
0306 set(DPMJET_LIB "DpmJetLib")
0307 message(STATUS "DPMJet objects: ${DPMJET_OBJECTS}")
0308 add_library(${DPMJET_LIB} STATIC dpmjet/dpmjetint.f ${DPMJET_OBJECTS})
0309 set(optionalLibs ${optionalLibs} ${DPMJET_LIB})
0310 set(optionalLibs ${optionalLibs} "gfortran")
0311
0312 endif()
0313
0314 if(ENABLE_PYTHIA6)
0315 enable_language(Fortran)
0316 endif()
0317
0318 # add starlight executable to the build system
0319 add_executable(starlight src/main.cpp)
0320 add_executable(e_starlight src/e_main.cpp)
0321 #target_link_libraries(starlight Starlib ${PYTHIA8_LIBRARY} ${LHAPDF_LIBRARIES} ${PYTHIA6_LIBRARY} ${DPMJET_LIB} )
0322 target_link_libraries(starlight Starlib ${optionalLibs})# ${CMAKE_THREAD_LIBS_INIT})
0323 target_link_libraries(e_starlight Starlib ${optionalLibs})# ${CMAKE_THREAD_LIBS_INIT})
0324
0325 #make_executable(starlight src/main.cpp ${THIS_LIB})
0326
0327 configure_file (
0328 "${PROJECT_SOURCE_DIR}/starlightconfig.h.in"
0329 "${PROJECT_BINARY_DIR}/starlightconfig.h"
0330 )
0331 # Erase xsec values in case changes in code affects the xsec, executed during make process
0332 add_custom_command (TARGET Starlib POST_BUILD COMMAND touch ARGS slight.txt)
0333 add_custom_command (TARGET Starlib POST_BUILD COMMAND cp ARGS slight.txt slight.txt.bak)
0334 add_custom_command (TARGET Starlib POST_BUILD COMMAND echo ARGS '' > slight.txt )
0335
0336
0337 message(STATUS "Cmake did not find any errors. run 'make' to build the project.")
0338 message(STATUS "On multi-core machines 'make -j#', where # is the number of parallel jobs, can speedup compilation considerably.")