diff --git a/cmake/Modules/CompilerFlags.cmake b/cmake/Modules/CompilerFlags.cmake index e3fa0ad..d0eb386 100644 --- a/cmake/Modules/CompilerFlags.cmake +++ b/cmake/Modules/CompilerFlags.cmake @@ -1,52 +1,55 @@ # 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} -Wall -Wextra -Wshadow -Woverloaded-virtual") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") + #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) # C++ standard settings set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) # 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/test/CMakeLists.txt b/test/CMakeLists.txt index e149173..6f1d3e7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,25 +1,29 @@ # the test executables require ROOT for histogramming etc. find_package(ROOT REQUIRED) -include(${ROOT_USE_FILE}) + +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 ${ROOT_LIBRARIES}) + 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) 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 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) diff --git a/validation/CMakeLists.txt b/validation/CMakeLists.txt index 750267d..d5855d0 100644 --- a/validation/CMakeLists.txt +++ b/validation/CMakeLists.txt @@ -1,55 +1,59 @@ # the validation executables require ROOT for histogramming etc. find_package(ROOT REQUIRED) -include(${ROOT_USE_FILE}) + +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 ${ROOT_LIBRARIES}) + 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() # 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)