diff --git a/CMakeLists.txt b/CMakeLists.txt index d75ac38..b3b13aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,154 +1,155 @@ ######################################################################## # Copyright 1998-2020 CERN for the benefit of the EvtGen authors # # # # This file is part of EvtGen. # # # # EvtGen is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # EvtGen is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with EvtGen. If not, see . # ######################################################################## # Top level CMakeLists.txt for EvtGen # Enforce an out-of-source build. # Should be the first action in the top level CMakeLists.txt if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(STATUS "EvtGen requires an out-of-source build.") message(STATUS "Please remove the following files from ${CMAKE_BINARY_DIR}:") message(STATUS " CMakeCache.txt") message(STATUS " CMakeFiles") message(STATUS "Once these files are removed, create a separate directory") message(STATUS "and run CMake from there, pointing it to:") message(STATUS " ${CMAKE_SOURCE_DIR}") message(FATAL_ERROR "in-source build detected") endif() # Also require a minimum version of CMake cmake_minimum_required(VERSION 3.11.0) # Project setup if(${CMAKE_VERSION} VERSION_LESS 3.12.0) project(EvtGen VERSION 2.0.0 DESCRIPTION "Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons." LANGUAGES C CXX ) else() project(EvtGen VERSION 2.0.0 DESCRIPTION "Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons." LANGUAGES C CXX HOMEPAGE_URL "https://evtgen.hepforge.org" ) endif() # Prepend this project's custom module path(s) to CMAKE_MODULE_PATH set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) # Include needed modules to perform any custom setup # Install paths include(GNUInstallDirs) # Compilation/linking flags and related settings include(CompilerFlags) # EvtGen external dependencies option(EVTGEN_HEPMC3 "Enable/disable linking with HepMC3" ON) option(EVTGEN_PYTHIA "Enable/disable linking with Pythia8" OFF) option(EVTGEN_PHOTOS "Enable/disable linking with Photos++" OFF) option(EVTGEN_TAUOLA "Enable/disable linking with Tauola++" OFF) +option(EVTGEN_SUPPRESS_EXTERNAL_WARNINGS "Enable/disable suppression of warnings from external dependencies" OFF) if (EVTGEN_HEPMC3) message(STATUS "EvtGen: Linking with HepMC3") else() message(STATUS "EvtGen: Linking with HepMC2") endif() message(STATUS "EvtGen: Optional linking with HepMC3 EVTGEN_HEPMC3 ${EVTGEN_HEPMC3}") message(STATUS "EvtGen: Optional linking with Pythia8 EVTGEN_PYTHIA ${EVTGEN_PYTHIA}") message(STATUS "EvtGen: Optional linking with Photos++ EVTGEN_PHOTOS ${EVTGEN_PHOTOS}") message(STATUS "EvtGen: Optional linking with Tauola++ EVTGEN_TAUOLA ${EVTGEN_TAUOLA}") include(ExternalDependencies) # Now build the library add_subdirectory(src) # Copy the particle property and decay tables configure_file(DECAY.DEC ${CMAKE_CURRENT_BINARY_DIR}/DECAY.DEC COPYONLY) configure_file(DECAY.XML ${CMAKE_CURRENT_BINARY_DIR}/DECAY.XML COPYONLY) configure_file(evt.pdl ${CMAKE_CURRENT_BINARY_DIR}/evt.pdl COPYONLY) # Copy the older decay tables configure_file(DECAY_2009.DEC ${CMAKE_CURRENT_BINARY_DIR}/DECAY_2009.DEC COPYONLY) configure_file(DECAY_2009.XML ${CMAKE_CURRENT_BINARY_DIR}/DECAY_2009.XML COPYONLY) configure_file(DECAY_2010.DEC ${CMAKE_CURRENT_BINARY_DIR}/DECAY_2010.DEC COPYONLY) configure_file(DECAY_2010.XML ${CMAKE_CURRENT_BINARY_DIR}/DECAY_2010.XML COPYONLY) # Build the executables in the test and validation directories option(EVTGEN_BUILD_DOC "Enable/disable building of userguide documentation in 'doc' directory" OFF) option(EVTGEN_BUILD_DOXYGEN "Enable/disable building of Doxygen documentation in 'doxygen' directory" OFF) option(EVTGEN_BUILD_TESTS "Enable/disable building of executables in 'test' directory" OFF) option(EVTGEN_BUILD_VALIDATIONS "Enable/disable building of executables in 'validation' directory" OFF) message(STATUS "EvtGen: Building of userguide documentation in 'doc' directory EVTGEN_BUILD_DOC ${EVTGEN_BUILD_DOC}") message(STATUS "EvtGen: Building of Doxygen documentation in 'doxygen' directory EVTGEN_BUILD_DOXYGEN ${EVTGEN_BUILD_DOXYGEN}") message(STATUS "EvtGen: Building of executables in 'test' directory EVTGEN_BUILD_TESTS ${EVTGEN_BUILD_TESTS}") message(STATUS "EvtGen: Building of executables in 'validation' directory EVTGEN_BUILD_VALIDATIONS ${EVTGEN_BUILD_VALIDATIONS}") if(EVTGEN_BUILD_DOC) add_subdirectory(doc) endif() if(EVTGEN_BUILD_DOXYGEN) add_subdirectory(doxygen) endif() if(EVTGEN_BUILD_TESTS) add_subdirectory(test) endif() if(EVTGEN_BUILD_VALIDATIONS) add_subdirectory(validation) endif() # Install the include directories install(DIRECTORY EvtGen DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY EvtGenBase DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY EvtGenExternal DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY EvtGenModels DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # Install the particle properties and decay tables install(FILES DECAY.DEC DECAY.XML evt.pdl DECAY_2010.XML DECAY_2010.DEC DECAY_2009.XML DECAY_2009.DEC DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJET_NAME}) # Install the COPYING and AUTHORS files install(FILES AUTHORS COPYING DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJET_NAME}) # Install the README and History files install(FILES README.md Pythia8_README.md Tauola_README.md History.md DESTINATION ${CMAKE_INSTALL_DOCDIR}/${CMAKE_PROJET_NAME}) # Generate CMake config files, which can be used by other projects include(CMakePackageConfigHelpers) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) set(DATA_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJET_NAME}) configure_package_config_file(cmake/Templates/EvtGenConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJET_NAME}/cmake PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR DATA_INSTALL_DIR ) write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfigVersion.cmake COMPATIBILITY AnyNewerVersion ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJET_NAME}/cmake ) install( EXPORT "EvtGenTargets" NAMESPACE "EvtGen::" DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJET_NAME}/cmake ) diff --git a/cmake/Modules/CompilerFlags.cmake b/cmake/Modules/CompilerFlags.cmake index e6bf114..30c8d79 100644 --- a/cmake/Modules/CompilerFlags.cmake +++ b/cmake/Modules/CompilerFlags.cmake @@ -1,83 +1,83 @@ ######################################################################## # Copyright 1998-2020 CERN for the benefit of the EvtGen authors # # # # This file is part of EvtGen. # # # # EvtGen is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # EvtGen is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with EvtGen. If not, see . # ######################################################################## # Set the build type (if not already specified) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "EvtGen: Setting build type to 'Release' as none was specified") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release, MinSizeRel, Debug, RelWithDebInfo" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") elseif(CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "EvtGen: Build type '${CMAKE_BUILD_TYPE}'") endif() # Set the warning/optimise/debug flags for each build type if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" ) - message(STATUS "EvtGen: Customising warning/optimise/debug flags for each build type") + message(STATUS "EvtGen: Customising compiler flags for each build type") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -Wall -Wextra -Wshadow -Woverloaded-virtual") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -Wall -Wextra") if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" ) set(CMAKE_CXX_FLAGS_DEBUG "-Og -g3") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g3") elseif( ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" ) set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") endif() else() - message(STATUS "EvtGen: No customisation of warning/optimise/debug flags implemented for compiler: ${CMAKE_CXX_COMPILER_ID}") + message(STATUS "EvtGen: No customisation of compiler flags implemented for compiler: ${CMAKE_CXX_COMPILER_ID}") endif() # Make sure our project's include directories always come first set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) # Prioritise UNIX-style packages over macOS frameworks set(CMAKE_FIND_FRAMEWORK LAST) # Control verbosity of the build set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "Control verbosity of generated Makefiles") # C++ standard settings set(CMAKE_CXX_EXTENSIONS OFF) if(DEFINED ENV{CMAKE_CXX_STANDARD}) set(CMAKE_CXX_STANDARD $ENV{CMAKE_CXX_STANDARD} CACHE STRING "C++ standard") else() set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard") endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) message(STATUS "EvtGen: Using C++${CMAKE_CXX_STANDARD} standard") # Special linker flags for MacOSX if (APPLE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -single_module -undefined dynamic_lookup") endif() # RPATH handling set(CMAKE_MACOSX_RPATH TRUE) set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 39ad2a7..dfbdcae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,236 +1,264 @@ ######################################################################## # Copyright 1998-2020 CERN for the benefit of the EvtGen authors # # # # This file is part of EvtGen. # # # # EvtGen is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # EvtGen is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with EvtGen. If not, see . # ######################################################################## # Use glob to find the sources for the main and external libraries file(GLOB EVTGEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenBase/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenModels/*.cpp ) file(GLOB EVTGEN_EXTERNAL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenExternal/*.cpp ) # Add the main EvtGen library... # First build all the object files (with PIC enabled) so they can be used to # build both the shared and static libs add_library(objlib OBJECT ${EVTGEN_SOURCES}) set_target_properties(objlib PROPERTIES POSITION_INDEPENDENT_CODE 1) target_compile_definitions(objlib PRIVATE EVTGEN_CPP11) target_include_directories(objlib PRIVATE ${CMAKE_SOURCE_DIR}) if(EVTGEN_HEPMC3) target_compile_definitions(objlib PRIVATE EVTGEN_HEPMC3) - target_include_directories(objlib PRIVATE ${HEPMC3_INCLUDE_DIR}) + if (EVTGEN_SUPPRESS_EXTERNAL_WARNINGS) + target_include_directories(objlib SYSTEM PRIVATE ${HEPMC3_INCLUDE_DIR}) + else() + target_include_directories(objlib PRIVATE ${HEPMC3_INCLUDE_DIR}) + endif() else() - target_include_directories(objlib PRIVATE ${HEPMC2_INCLUDE_DIR}) + if (EVTGEN_SUPPRESS_EXTERNAL_WARNINGS) + target_include_directories(objlib SYSTEM PRIVATE ${HEPMC2_INCLUDE_DIR}) + else() + target_include_directories(objlib PRIVATE ${HEPMC2_INCLUDE_DIR}) + endif() endif() # Now make the shared library from the object files add_library(EvtGen SHARED $) set_target_properties(EvtGen PROPERTIES OUTPUT_NAME EvtGen) set_target_properties(EvtGen PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) set_target_properties(EvtGen PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) target_compile_definitions(EvtGen PUBLIC EVTGEN_CPP11) target_include_directories(EvtGen PUBLIC $ $) if(EVTGEN_HEPMC3) target_compile_definitions(EvtGen PUBLIC EVTGEN_HEPMC3) target_include_directories(EvtGen PUBLIC ${HEPMC3_INCLUDE_DIR}) target_link_libraries(EvtGen PUBLIC ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB}) else() target_include_directories(EvtGen PUBLIC ${HEPMC2_INCLUDE_DIR}) target_link_libraries(EvtGen PUBLIC ${HEPMC2_LIBRARIES}) endif() # Now make the static library from the object files add_library(EvtGenStatic STATIC $) set_target_properties(EvtGenStatic PROPERTIES OUTPUT_NAME EvtGen) set_target_properties(EvtGenStatic PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) target_compile_definitions(EvtGenStatic PUBLIC EVTGEN_CPP11) target_include_directories(EvtGenStatic PUBLIC $ $) if(EVTGEN_HEPMC3) target_compile_definitions(EvtGenStatic PUBLIC EVTGEN_HEPMC3) target_include_directories(EvtGenStatic PUBLIC ${HEPMC3_INCLUDE_DIR}) target_link_libraries(EvtGenStatic PUBLIC ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB}) else() target_include_directories(EvtGenStatic PUBLIC ${HEPMC2_INCLUDE_DIR}) target_link_libraries(EvtGenStatic PUBLIC ${HEPMC2_LIBRARIES}) endif() # Add the EvtGenExternal library (if required)... if( EVTGEN_PYTHIA OR EVTGEN_PHOTOS OR EVTGEN_TAUOLA ) # Again, first build all the object files (with PIC enabled) so they can be # used to build both the shared and static libs add_library(objlib_ext OBJECT ${EVTGEN_EXTERNAL_SOURCES}) set_target_properties(objlib_ext PROPERTIES POSITION_INDEPENDENT_CODE 1) target_compile_definitions(objlib_ext PRIVATE EVTGEN_CPP11) target_include_directories(objlib_ext PRIVATE ${CMAKE_SOURCE_DIR}) if(EVTGEN_HEPMC3) target_compile_definitions(objlib_ext PRIVATE EVTGEN_HEPMC3) - target_include_directories(objlib_ext PRIVATE ${HEPMC3_INCLUDE_DIR}) + if (EVTGEN_SUPPRESS_EXTERNAL_WARNINGS) + target_include_directories(objlib_ext SYSTEM PRIVATE ${HEPMC3_INCLUDE_DIR}) + else() + target_include_directories(objlib_ext PRIVATE ${HEPMC3_INCLUDE_DIR}) + endif() else() - target_include_directories(objlib_ext PRIVATE ${HEPMC2_INCLUDE_DIR}) + if (EVTGEN_SUPPRESS_EXTERNAL_WARNINGS) + target_include_directories(objlib_ext SYSTEM PRIVATE ${HEPMC2_INCLUDE_DIR}) + else() + target_include_directories(objlib_ext PRIVATE ${HEPMC2_INCLUDE_DIR}) + endif() endif() if(EVTGEN_PYTHIA) target_compile_definitions(objlib_ext PRIVATE EVTGEN_PYTHIA) - target_include_directories(objlib_ext PRIVATE ${PYTHIA8_INCLUDE_DIRS}) + if (EVTGEN_SUPPRESS_EXTERNAL_WARNINGS) + target_include_directories(objlib_ext SYSTEM PRIVATE ${PYTHIA8_INCLUDE_DIRS}) + else() + target_include_directories(objlib_ext PRIVATE ${PYTHIA8_INCLUDE_DIRS}) + endif() endif() if(EVTGEN_PHOTOS) target_compile_definitions(objlib_ext PRIVATE EVTGEN_PHOTOS) - target_include_directories(objlib_ext PRIVATE ${Photos++_INCLUDE_DIRS}) + if (EVTGEN_SUPPRESS_EXTERNAL_WARNINGS) + target_include_directories(objlib_ext SYSTEM PRIVATE ${Photos++_INCLUDE_DIRS}) + else() + target_include_directories(objlib_ext PRIVATE ${Photos++_INCLUDE_DIRS}) + endif() endif() if(EVTGEN_TAUOLA) target_compile_definitions(objlib_ext PRIVATE EVTGEN_TAUOLA) - target_include_directories(objlib_ext PRIVATE ${Tauola++_INCLUDE_DIRS}) + if (EVTGEN_SUPPRESS_EXTERNAL_WARNINGS) + target_include_directories(objlib_ext SYSTEM PRIVATE ${Tauola++_INCLUDE_DIRS}) + else() + target_include_directories(objlib_ext PRIVATE ${Tauola++_INCLUDE_DIRS}) + endif() endif() # Now make the shared library from the object files add_library(EvtGenExternal SHARED $) set_target_properties(EvtGenExternal PROPERTIES OUTPUT_NAME EvtGenExternal) set_target_properties(EvtGenExternal PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) set_target_properties(EvtGenExternal PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) target_compile_definitions(EvtGenExternal PUBLIC EVTGEN_CPP11) target_include_directories(EvtGenExternal PUBLIC $ $) if(EVTGEN_PYTHIA) target_compile_definitions(EvtGenExternal PUBLIC EVTGEN_PYTHIA) target_include_directories(EvtGenExternal PUBLIC ${PYTHIA8_INCLUDE_DIRS}) target_link_libraries(EvtGenExternal PUBLIC ${PYTHIA8_LIBRARIES}) endif() if(EVTGEN_HEPMC3) target_compile_definitions(EvtGenExternal PUBLIC EVTGEN_HEPMC3) target_include_directories(EvtGenExternal PUBLIC ${HEPMC3_INCLUDE_DIR}) target_link_libraries(EvtGenExternal PUBLIC ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB}) if(EVTGEN_PHOTOS) target_compile_definitions(EvtGenExternal PUBLIC EVTGEN_PHOTOS) target_include_directories(EvtGenExternal PUBLIC ${Photos++_INCLUDE_DIRS}) # From version 3.64 Photos has HepMC3 support target_link_libraries(EvtGenExternal PUBLIC ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC3_LIBRARY}) endif() if(EVTGEN_TAUOLA) target_compile_definitions(EvtGenExternal PUBLIC EVTGEN_TAUOLA) target_include_directories(EvtGenExternal PUBLIC ${Tauola++_INCLUDE_DIRS}) # From version 1.1.8 Tauola has HepMC3 support target_link_libraries(EvtGenExternal PUBLIC ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY} ${Tauola++_HepMC3_LIBRARY}) endif() else() target_include_directories(EvtGenExternal PUBLIC ${HEPMC2_INCLUDE_DIR}) target_link_libraries(EvtGenExternal PUBLIC ${HEPMC2_LIBRARIES}) if(EVTGEN_PHOTOS) target_compile_definitions(EvtGenExternal PUBLIC EVTGEN_PHOTOS) target_include_directories(EvtGenExternal PUBLIC ${Photos++_INCLUDE_DIRS}) # Photos has different library structures for versions before and after 3.58 # so we need to check which one we have if(Photos++_pp_FOUND AND Photos++_ppHepMC_FOUND) message(STATUS "EvtGen: PHOTOS has pp and ppHepMC components") target_link_libraries(EvtGenExternal PUBLIC ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC_LIBRARY}) elseif(Photos++_CxxInterface_FOUND AND Photos++_Fortran_FOUND) message(STATUS "EvtGen: PHOTOS has CxxInterface and Fortran components") target_link_libraries(EvtGenExternal PUBLIC ${Photos++_CxxInterface_LIBRARY} ${Photos++_Fortran_LIBRARY}) else() message(ERROR "EvtGen: PHOTOS lacks pp+ppHepMC or CxxInterface+Fortran components") endif() endif() if(EVTGEN_TAUOLA) target_compile_definitions(EvtGenExternal PUBLIC EVTGEN_TAUOLA) target_include_directories(EvtGenExternal PUBLIC ${Tauola++_INCLUDE_DIRS}) target_link_libraries(EvtGenExternal PUBLIC ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY}) # Older versions of Tauola don't have the HepMC component, the HepMC2 interface is in CxxInterface if(Tauola++_HepMC_FOUND) target_link_libraries(EvtGenExternal PUBLIC ${Tauola++_HepMC_LIBRARY}) endif() endif() endif() # Now make the static library from the object files add_library(EvtGenExternalStatic STATIC $) set_target_properties(EvtGenExternalStatic PROPERTIES OUTPUT_NAME EvtGenExternal) set_target_properties(EvtGenExternalStatic PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) target_compile_definitions(EvtGenExternalStatic PUBLIC EVTGEN_CPP11) target_include_directories(EvtGenExternalStatic PUBLIC $ $) if(EVTGEN_PYTHIA) target_compile_definitions(EvtGenExternalStatic PUBLIC EVTGEN_PYTHIA) target_include_directories(EvtGenExternalStatic PUBLIC ${PYTHIA8_INCLUDE_DIRS}) target_link_libraries(EvtGenExternalStatic PUBLIC ${PYTHIA8_LIBRARIES}) endif() if(EVTGEN_HEPMC3) target_compile_definitions(EvtGenExternalStatic PUBLIC EVTGEN_HEPMC3) target_include_directories(EvtGenExternalStatic PUBLIC ${HEPMC3_INCLUDE_DIR}) target_link_libraries(EvtGenExternalStatic PUBLIC ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB}) if(EVTGEN_PHOTOS) target_compile_definitions(EvtGenExternalStatic PUBLIC EVTGEN_PHOTOS) target_include_directories(EvtGenExternalStatic PUBLIC ${Photos++_INCLUDE_DIRS}) # From version 3.64 Photos has HepMC3 support target_link_libraries(EvtGenExternalStatic PUBLIC ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC3_LIBRARY}) endif() if(EVTGEN_TAUOLA) target_compile_definitions(EvtGenExternalStatic PUBLIC EVTGEN_TAUOLA) target_include_directories(EvtGenExternalStatic PUBLIC ${Tauola++_INCLUDE_DIRS}) # From version 1.1.8 Tauola has HepMC3 support target_link_libraries(EvtGenExternalStatic PUBLIC ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY} ${Tauola++_HepMC3_LIBRARY}) endif() else() target_include_directories(EvtGenExternalStatic PUBLIC ${HEPMC2_INCLUDE_DIR}) target_link_libraries(EvtGenExternalStatic PUBLIC ${HEPMC2_LIBRARIES}) if(EVTGEN_PHOTOS) target_compile_definitions(EvtGenExternalStatic PUBLIC EVTGEN_PHOTOS) target_include_directories(EvtGenExternalStatic PUBLIC ${Photos++_INCLUDE_DIRS}) # Photos has different library structures for versions before and after 3.58 # so we need to check which one we have if(Photos++_pp_FOUND AND Photos++_ppHepMC_FOUND) #message(STATUS "EvtGen: PHOTOS has pp and ppHepMC components") target_link_libraries(EvtGenExternalStatic PUBLIC ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC_LIBRARY}) elseif(Photos++_CxxInterface_FOUND AND Photos++_Fortran_FOUND) #message(STATUS "EvtGen: PHOTOS has CxxInterface and Fortran components") target_link_libraries(EvtGenExternalStatic PUBLIC ${Photos++_CxxInterface_LIBRARY} ${Photos++_Fortran_LIBRARY}) else() message(ERROR "EvtGen: PHOTOS lacks pp+ppHepMC or CxxInterface+Fortran components") endif() endif() if(EVTGEN_TAUOLA) target_compile_definitions(EvtGenExternalStatic PUBLIC EVTGEN_TAUOLA) target_include_directories(EvtGenExternalStatic PUBLIC ${Tauola++_INCLUDE_DIRS}) target_link_libraries(EvtGenExternalStatic PUBLIC ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY}) # Older versions of Tauola don't have the HepMC component, the HepMC2 interface is in CxxInterface if(Tauola++_HepMC_FOUND) target_link_libraries(EvtGenExternalStatic PUBLIC ${Tauola++_HepMC_LIBRARY}) endif() endif() endif() endif() # Install the libraries install( TARGETS EvtGen EvtGenStatic EXPORT "EvtGenTargets" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) if( EVTGEN_PYTHIA OR EVTGEN_PHOTOS OR EVTGEN_TAUOLA ) install( TARGETS EvtGenExternal EvtGenExternalStatic EXPORT "EvtGenTargets" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) endif()