diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d85f46..06cfbdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,108 +1,104 @@ # 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.8.0) +cmake_minimum_required(VERSION 3.11.0) # Project setup -if(${CMAKE_VERSION} VERSION_LESS 3.9.0) - project(EvtGen - VERSION 2.0.0 - ) -elseif(${CMAKE_VERSION} VERSION_LESS 3.12.0) +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) message(STATUS "EvtGen: Linking with HepMC2") message(STATUS "EvtGen: Optional linking with Pythia8 ${EVTGEN_PYTHIA}") message(STATUS "EvtGen: Optional linking with Photos++ ${EVTGEN_PHOTOS}") message(STATUS "EvtGen: Optional linking with 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) # 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}") message(STATUS "EvtGen: Building of executables in 'validation' directory ${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_PREFIX}) # 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_PREFIX}/cmake ) install( EXPORT "EvtGenTargets" NAMESPACE "EvtGen::" DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake ) diff --git a/cmake/Modules/CompilerFlags.cmake b/cmake/Modules/CompilerFlags.cmake index d0eb386..0f78e7c 100644 --- a/cmake/Modules/CompilerFlags.cmake +++ b/cmake/Modules/CompilerFlags.cmake @@ -1,55 +1,56 @@ # 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") #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}") endif() # Make sure our project's include directories always come first set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) # Control verbosity of the build -set(CMAKE_VERBOSE_MAKEFILE OFF) +set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "Control verbosity of generated Makefiles") # C++ standard settings set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard") 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/cmake/Modules/ExternalDependencies.cmake b/cmake/Modules/ExternalDependencies.cmake index 78b3990..d34e95d 100644 --- a/cmake/Modules/ExternalDependencies.cmake +++ b/cmake/Modules/ExternalDependencies.cmake @@ -1,20 +1,20 @@ -set(HEPMC2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/HepMC" CACHE STRING "Location of HepMC 2 installation") +set(HEPMC2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/HepMC" CACHE PATH "Location of HepMC 2 installation") if(DEFINED ENV{PYTHIAVER}) - set(PYTHIA8_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/pythia$ENV{PYTHIAVER}" CACHE STRING "Location of Pythia8 installation") + 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 STRING "Location of Pythia8 installation") + set(PYTHIA8_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/pythia8230" CACHE PATH "Location of Pythia8 installation") endif() -set(PHOTOSPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/PHOTOS" CACHE STRING "Location of Photos++ installation") -set(TAUOLAPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/TAUOLA" CACHE STRING "Location of Tauola++ installation") +set(PHOTOSPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/PHOTOS" CACHE PATH "Location of Photos++ installation") +set(TAUOLAPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/TAUOLA" CACHE PATH "Location of Tauola++ installation") find_package(HepMC2 REQUIRED) if(${EVTGEN_PYTHIA}) find_package(Pythia8 REQUIRED) endif() if(${EVTGEN_PHOTOS}) find_package(Photos++ REQUIRED) endif() if(${EVTGEN_TAUOLA}) find_package(Tauola++ REQUIRED) endif()