diff --git a/CMakeLists.txt b/CMakeLists.txt index 3efcbd8..daa1b5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,111 +1,111 @@ # 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." ) 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." 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_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_HEPMC3 "Enable/disable linking with HepMC3" ON) if (EVTGEN_HEPMC3) -message(STATUS "EvtGen: Linking with HepMC3") + message(STATUS "EvtGen: Linking with HepMC3") else() -message(STATUS "EvtGen: Linking with HepMC2") + message(STATUS "EvtGen: Linking with HepMC2") endif() 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}") -message(STATUS "EvtGen: Optional linking with HepMC3 EVTGEN_HEPMC3 ${EVTGEN_HEPMC3}") +message(STATUS "EvtGen: Optional linking with HepMC3 EVTGEN_HEPMC3 ${EVTGEN_HEPMC3}") 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) # Build the executables in the test and validation directories 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 executables in 'test' directory EVTGEN_BUILD_TESTS ${EVTGEN_BUILD_TESTS}") +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_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 DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen) # 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}) configure_package_config_file(cmake/Templates/EvtGenConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfig.cmake INSTALL_DESTINATION cmake PATH_VARS INCLUDE_INSTALL_DIR LIB_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}/EvtGen/cmake ) install( EXPORT "EvtGenTargets" NAMESPACE "EvtGen::" DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen/cmake ) diff --git a/cmake/Modules/ExternalDependencies.cmake b/cmake/Modules/ExternalDependencies.cmake index 64c7ab2..dae947a 100644 --- a/cmake/Modules/ExternalDependencies.cmake +++ b/cmake/Modules/ExternalDependencies.cmake @@ -1,38 +1,44 @@ -set(HEPMC2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/HepMC" CACHE PATH "Location of HepMC 2 installation") +set(HEPMC2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/HepMC" CACHE PATH "Location of HepMC 2 installation") set(HEPMC3_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/HepMC3" CACHE PATH "Location of HepMC 3 installation") if(DEFINED ENV{PYTHIAVER}) set(PYTHIA8_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/pythia$ENV{PYTHIAVER}" CACHE PATH "Location of Pythia8 installation") else() - set(PYTHIA8_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/pythia8230" CACHE PATH "Location of Pythia8 installation") + set(PYTHIA8_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/pythia8" CACHE PATH "Location of Pythia8 installation") endif() set(Photos++_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/PHOTOS" CACHE PATH "Location of Photos++ installation") set(Tauola++_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/TAUOLA" CACHE PATH "Location of Tauola++ installation") set(PHOTOSPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/PHOTOS" CACHE PATH "Location of Photos++ installation/alternative spelling") set(TAUOLAPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/TAUOLA" CACHE PATH "Location of Tauola++ installation/alternative spelling") -#Here we are looking for HepMC interfaces. Note that the OPTIONAL_COMPONENTS includes the libraries that appear only in the new TAUOLA/PHOTOS -if (EVTGEN_HEPMC3) -find_package(HepMC3 REQUIRED) -if(${EVTGEN_PYTHIA}) - find_package(Pythia8 REQUIRED) -endif() -if(${EVTGEN_PHOTOS}) - find_package(Photos++ REQUIRED COMPONENTS pp ppHepMC3) -endif() -if(${EVTGEN_TAUOLA}) - find_package(Tauola++ REQUIRED COMPONENTS Fortran CxxInterface HepMC3) -endif() +# The components we search for in the external generators depend on the version +# of HepMC we're working with +if(EVTGEN_HEPMC3) + find_package(HepMC3 REQUIRED PATHS ${HEPMC3_ROOT_DIR}) + if(EVTGEN_PYTHIA) + find_package(Pythia8 REQUIRED) + endif() + if(EVTGEN_PHOTOS) + # From version 3.64 Photos has HepMC3 support + find_package(Photos++ REQUIRED COMPONENTS pp ppHepMC3) + endif() + if(EVTGEN_TAUOLA) + # From version 1.1.8 Tauola has HepMC3 support + find_package(Tauola++ REQUIRED COMPONENTS Fortran CxxInterface HepMC3) + endif() else() -find_package(HepMC2 REQUIRED) -if(${EVTGEN_PYTHIA}) - find_package(Pythia8 REQUIRED) -endif() -if(${EVTGEN_PHOTOS}) - find_package(Photos++ REQUIRED OPTIONAL_COMPONENTS pp ppHepMC CxxInterface Fortran) -endif() -if(${EVTGEN_TAUOLA}) - find_package(Tauola++ REQUIRED COMPONENTS Fortran CxxInterface OPTIONAL_COMPONENTS HepMC) -endif() + find_package(HepMC2 REQUIRED) + if(EVTGEN_PYTHIA) + find_package(Pythia8 REQUIRED) + endif() + if(EVTGEN_PHOTOS) + # Photos has different library structures for versions before and after 3.58 + # so we need to search for either option: pp+ppHepMC or CxxInterface+Fortran + find_package(Photos++ REQUIRED OPTIONAL_COMPONENTS pp ppHepMC CxxInterface Fortran) + endif() + if(EVTGEN_TAUOLA) + # Older versions of Tauola don't have the HepMC component, the HepMC2 interface is in CxxInterface + find_package(Tauola++ REQUIRED COMPONENTS Fortran CxxInterface OPTIONAL_COMPONENTS HepMC) + endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e78aaec..120ce65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,181 +1,216 @@ # 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_include_directories(objlib PRIVATE ${CMAKE_SOURCE_DIR}) - target_compile_definitions(objlib PRIVATE EVTGEN_CPP11) -if (EVTGEN_HEPMC3) -target_compile_definitions(objlib PRIVATE EVTGEN_HEPMC3) -target_include_directories(objlib PRIVATE ${HEPMC3_INCLUDE_DIR}) +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}) else() -target_include_directories(objlib PRIVATE ${HEPMC2_INCLUDE_DIR}) + target_include_directories(objlib PRIVATE ${HEPMC2_INCLUDE_DIR}) 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_include_directories(EvtGen PUBLIC ${HEPMC3_INCLUDE_DIR}) -target_link_libraries(EvtGen ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB} ) +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 ${HEPMC2_LIBRARIES}) + target_include_directories(EvtGen PUBLIC ${HEPMC2_INCLUDE_DIR}) + target_link_libraries(EvtGen PUBLIC ${HEPMC2_LIBRARIES}) endif() -target_compile_definitions(EvtGen PUBLIC EVTGEN_CPP11) - - +# 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}/archive) +target_compile_definitions(EvtGenStatic PUBLIC EVTGEN_CPP11) target_include_directories(EvtGenStatic PUBLIC $ $) -if (EVTGEN_HEPMC3) -target_include_directories(EvtGenStatic PUBLIC ${HEPMC3_INCLUDE_DIR}) -target_link_libraries(EvtGenStatic ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB} ) +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 ${HEPMC2_LIBRARIES}) + target_include_directories(EvtGenStatic PUBLIC ${HEPMC2_INCLUDE_DIR}) + target_link_libraries(EvtGenStatic PUBLIC ${HEPMC2_LIBRARIES}) endif() -target_compile_definitions(EvtGenStatic PUBLIC EVTGEN_CPP11) -# Add the EvtGenExternal library... -if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) +# 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_include_directories(objlib_ext PUBLIC ${HEPMC3_INCLUDE_DIR}) - target_compile_definitions(objlib_ext PRIVATE EVTGEN_HEPMC3) + if(EVTGEN_HEPMC3) + target_compile_definitions(objlib_ext PRIVATE EVTGEN_HEPMC3) + target_include_directories(objlib_ext PRIVATE ${HEPMC3_INCLUDE_DIR}) else() - target_include_directories(objlib_ext PUBLIC ${HEPMC2_INCLUDE_DIR}) + target_include_directories(objlib_ext PRIVATE ${HEPMC2_INCLUDE_DIR}) endif() - target_compile_definitions(objlib_ext PRIVATE EVTGEN_CPP11) - if(${EVTGEN_PYTHIA}) - target_include_directories(objlib_ext PRIVATE ${PYTHIA8_INCLUDE_DIRS}) + if(EVTGEN_PYTHIA) target_compile_definitions(objlib_ext PRIVATE EVTGEN_PYTHIA) + target_include_directories(objlib_ext PRIVATE ${PYTHIA8_INCLUDE_DIRS}) endif() - if(${EVTGEN_PHOTOS}) - target_include_directories(objlib_ext PRIVATE ${Photos++_INCLUDE_DIRS}) + if(EVTGEN_PHOTOS) target_compile_definitions(objlib_ext PRIVATE EVTGEN_PHOTOS) + target_include_directories(objlib_ext PRIVATE ${Photos++_INCLUDE_DIRS}) endif() - if(${EVTGEN_TAUOLA}) - target_include_directories(objlib_ext PRIVATE ${Tauola++_INCLUDE_DIRS}) + if(EVTGEN_TAUOLA) target_compile_definitions(objlib_ext PRIVATE EVTGEN_TAUOLA) + target_include_directories(objlib_ext PRIVATE ${Tauola++_INCLUDE_DIRS}) 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}) - - if(${EVTGEN_PYTHIA}) - target_link_libraries(EvtGenExternal ${PYTHIA8_LIBRARIES}) - endif() - - - if (EVTGEN_HEPMC3) - target_link_libraries(EvtGenExternal ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB} ) - if(${EVTGEN_PHOTOS}) - target_link_libraries(EvtGenExternal ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC3_LIBRARY} ) + 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_TAUOLA}) - target_link_libraries(EvtGenExternal ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY} ${Tauola++_HepMC3_LIBRARY}) - endif() - else() - target_link_libraries(EvtGenExternal ${HEPMC2_LIBRARIES}) - if(${EVTGEN_PHOTOS}) -#Photos should always have ppHepMC for compilation with HepMC2 - if (Photos++_pp_FOUND AND Photos++_ppHepMC_FOUND ) - message(STATUS "EvtGen: PHOTOS has pp and ppHepMC components") - target_link_libraries(EvtGenExternal ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC_LIBRARY}) - else() - if(Photos++_CxxInterface_FOUND AND Photos++_Fortran_FOUND ) - message(STATUS "EvtGen: PHOTOS has CxxInterface and Fortran components") - target_link_libraries(EvtGenExternal ${Photos++_CxxInterface_LIBRARY} ${Photos++_Fortran_LIBRARY}) - else() - message(ERROR "EvtGen: PHOTOS lacks pp+ppHepMC or CxxInterface+Fortran components") + 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() - endif() - if(${EVTGEN_TAUOLA}) - target_link_libraries(EvtGenExternal ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY}) -#The old versions of Tauola don't have HepMC, the HepMC2 interface is in CxxInterface - if (Tauola++_HepMC_FOUND) - target_link_libraries(EvtGenExternal ${Tauola++_HepMC_LIBRARY}) + 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() 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}/archive) - if(${EVTGEN_PYTHIA}) - target_link_libraries(EvtGenExternalStatic ${PYTHIA8_LIBRARIES}) - endif() - if (EVTGEN_HEPMC3) - target_link_libraries(EvtGenExternalStatic ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB} ) - if(${EVTGEN_PHOTOS}) - target_link_libraries(EvtGenExternalStatic ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC3_LIBRARY}) + 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_TAUOLA}) - target_link_libraries(EvtGenExternalStatic ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY} ${Tauola++_HepMC3_LIBRARY}) - endif() - else() - if(${EVTGEN_PHOTOS}) - if (Photos++_pp_FOUND AND Photos++_ppHepMC_FOUND ) - message(STATUS "EvtGen: PHOTOS has pp and ppHepMC components") - target_link_libraries(EvtGenExternal ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC_LIBRARY}) - else() - if(Photos++_CxxInterface_FOUND AND Photos++_Fortran_FOUND ) - message(STATUS "EvtGen: PHOTOS has CxxInterface and Fortran components") - target_link_libraries(EvtGenExternal ${Photos++_CxxInterface_LIBRARY} ${Photos++_Fortran_LIBRARY}) - else() - message(ERROR "EvtGen: PHOTOS lacks pp+ppHepMC or CxxInterface+Fortran components") + 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() - endif() - if(${EVTGEN_TAUOLA}) - target_link_libraries(EvtGenExternalStatic ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY}) - if (Tauola++_HepMC_FOUND) - target_link_libraries(EvtGenExternalStatic ${Tauola++_HepMC_LIBRARY} ) + 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() - target_link_libraries(EvtGenExternalStatic ${HEPMC2_LIBRARIES}) endif() endif() # Install the libraries install( TARGETS EvtGen EvtGenStatic EXPORT "EvtGenTargets" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/archive ) -if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) +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}/archive ) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2f18f47..e8800dd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,33 +1,35 @@ # the test executables require ROOT for histogramming etc. -find_package(ROOT QUIET COMPONENTS Hist) +find_package(ROOT QUIET COMPONENTS Hist) if (ROOT_FOUND) -add_library(root_interface INTERFACE IMPORTED) -target_include_directories(root_interface INTERFACE ${ROOT_INCLUDE_DIRS}) -target_link_libraries(root_interface INTERFACE ${ROOT_LIBRARIES}) + add_library(root_interface INTERFACE IMPORTED) + target_include_directories(root_interface INTERFACE ${ROOT_INCLUDE_DIRS}) + target_link_libraries(root_interface INTERFACE ${ROOT_LIBRARIES}) -# build each of the executables -foreach( test_exe evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC ) - add_executable(${test_exe} ${test_exe}.cc) - target_link_libraries(${test_exe} PRIVATE EvtGen) - if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) - target_compile_definitions(${test_exe} PRIVATE EVTGEN_EXTERNAL) - target_link_libraries(${test_exe} PRIVATE EvtGenExternal) + # build each of the executables + foreach( test_exe evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC ) + add_executable(${test_exe} ${test_exe}.cc) + target_link_libraries(${test_exe} PRIVATE EvtGen) if (EVTGEN_HEPMC3) - target_compile_definitions(${test_exe} PRIVATE EVTGEN_HEPMC3) + target_compile_definitions(${test_exe} PRIVATE EVTGEN_HEPMC3) endif() - endif() - target_link_libraries(${test_exe} PRIVATE root_interface) -endforeach() + if( EVTGEN_PYTHIA OR EVTGEN_PHOTOS OR EVTGEN_TAUOLA ) + target_compile_definitions(${test_exe} PRIVATE EVTGEN_EXTERNAL) + target_link_libraries(${test_exe} PRIVATE EvtGenExternal) + endif() + target_link_libraries(${test_exe} PRIVATE root_interface) + endforeach() -# install the executables -install(TARGETS evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC - RUNTIME DESTINATION test - ) + # install the executables + install(TARGETS evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC + RUNTIME DESTINATION test + ) -# install the decay files, macros, scripts, etc. -install(DIRECTORY exampleFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/test) -install(FILES do_tests - DESTINATION ${CMAKE_INSTALL_PREFIX}/test - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) -endif() \ No newline at end of file + # install the decay files, macros, scripts, etc. + install(DIRECTORY exampleFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/test) + install(FILES do_tests + DESTINATION ${CMAKE_INSTALL_PREFIX}/test + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +else() + message(WARNING "Could not find ROOT, cannot build test executables") +endif() diff --git a/validation/CMakeLists.txt b/validation/CMakeLists.txt index 91d09ea..f8c327e 100644 --- a/validation/CMakeLists.txt +++ b/validation/CMakeLists.txt @@ -1,60 +1,65 @@ # the validation executables require ROOT for histogramming etc. find_package(ROOT QUIET COMPONENTS Hist) if (ROOT_FOUND) -add_library(root_interface INTERFACE IMPORTED) -target_include_directories(root_interface INTERFACE ${ROOT_INCLUDE_DIRS}) -target_link_libraries(root_interface INTERFACE ${ROOT_LIBRARIES}) + add_library(root_interface INTERFACE IMPORTED) + target_include_directories(root_interface INTERFACE ${ROOT_INCLUDE_DIRS}) + target_link_libraries(root_interface INTERFACE ${ROOT_LIBRARIES}) -# build each of the executables -foreach( validation_exe compareRootFiles genExampleRootFiles genRootDecayChain testCPVDecays ) - add_executable(${validation_exe} ${validation_exe}.cc) - target_link_libraries(${validation_exe} PRIVATE EvtGen) - if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) - target_compile_definitions(${validation_exe} PRIVATE EVTGEN_EXTERNAL) - target_link_libraries(${validation_exe} PRIVATE EvtGenExternal) - endif() - target_link_libraries(${validation_exe} PRIVATE root_interface) -endforeach() + # build each of the executables + foreach( validation_exe compareRootFiles genExampleRootFiles genRootDecayChain testCPVDecays ) + add_executable(${validation_exe} ${validation_exe}.cc) + target_link_libraries(${validation_exe} PRIVATE EvtGen) + if (EVTGEN_HEPMC3) + target_compile_definitions(${test_exe} PRIVATE EVTGEN_HEPMC3) + endif() + if( EVTGEN_PYTHIA OR EVTGEN_PHOTOS OR EVTGEN_TAUOLA ) + target_compile_definitions(${validation_exe} PRIVATE EVTGEN_EXTERNAL) + target_link_libraries(${validation_exe} PRIVATE EvtGenExternal) + endif() + target_link_libraries(${validation_exe} PRIVATE root_interface) + endforeach() -# install the executables -install(TARGETS compareRootFiles genExampleRootFiles genRootDecayChain testCPVDecays - RUNTIME DESTINATION validation - ) + # install the executables + install(TARGETS compareRootFiles genExampleRootFiles genRootDecayChain testCPVDecays + RUNTIME DESTINATION validation + ) -# install the decay files, macros, scripts, etc. -install(DIRECTORY B0Files DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY CPVDecayFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY UpsilonFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY TauolaFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY Bs0Files DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY tauFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY rootFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY PHSPFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY BpFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY gifFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(DIRECTORY DalitzFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(FILES BKstarGamma.dec BuDst0rhop.dec Kspimumu.dec photosTest.dec DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(FILES compareDalitz.C PhaseSpacePlots.C photosPlots.C plotBKstarGamma.C PlotKspimumu.C DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) -install(FILES compareAllDecays.sh - compareB0PythiaDecays.sh - compareBpPythiaDecays.sh - compareBs0PythiaDecays.sh - compareTauolaDecays.sh - compareTauPythiaDecays.sh - compareUpsilonPythiaDecays.sh - genAllDecayExamples.sh - genB0PythiaDecays.sh - genBpPythiaDecays.sh - genBs0PythiaDecays.sh - genDalitzDecays.sh - genDDalitzModes.sh - genPHSP.sh - genTauolaDecays.sh - genTauPythiaDecays.sh - genUpsilonPythiaDecays.sh - runKspimumu.sh - runPhotosTest.sh - DESTINATION ${CMAKE_INSTALL_PREFIX}/validation - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + # install the decay files, macros, scripts, etc. + install(DIRECTORY B0Files DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY CPVDecayFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY UpsilonFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY TauolaFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY Bs0Files DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY tauFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY rootFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY PHSPFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY BpFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY gifFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(DIRECTORY DalitzFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(FILES BKstarGamma.dec BuDst0rhop.dec Kspimumu.dec photosTest.dec DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(FILES compareDalitz.C PhaseSpacePlots.C photosPlots.C plotBKstarGamma.C PlotKspimumu.C DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) + install(FILES compareAllDecays.sh + compareB0PythiaDecays.sh + compareBpPythiaDecays.sh + compareBs0PythiaDecays.sh + compareTauolaDecays.sh + compareTauPythiaDecays.sh + compareUpsilonPythiaDecays.sh + genAllDecayExamples.sh + genB0PythiaDecays.sh + genBpPythiaDecays.sh + genBs0PythiaDecays.sh + genDalitzDecays.sh + genDDalitzModes.sh + genPHSP.sh + genTauolaDecays.sh + genTauPythiaDecays.sh + genUpsilonPythiaDecays.sh + runKspimumu.sh + runPhotosTest.sh + DESTINATION ${CMAKE_INSTALL_PREFIX}/validation + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +else() + message(WARNING "Could not find ROOT, cannot build validation executables") endif()