diff --git a/CMakeLists.txt b/CMakeLists.txt index 4253c0d0068acd5ff1b6c7b83ac60f1efd06895d..83b240a910c40c9c53caf7788b4b9a6da4acc019 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,79 +33,85 @@ set (CMAKE_CXX_EXTENSIONS OFF) enable_testing () set (CTEST_OUTPUT_ON_FAILURE 1) +# Set the possible values of build type for cmake-gui and command line check +set (ALLOWED_BUILD_TYPES Debug Release MinSizeRel RelWithDebInfo Coverage) +set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${ALLOWED_BUILD_TYPES}) + # Set a default build type if none was specified -set (default_build_type "Release") +# by default: "Debug", if local ".git" directory is found, otherwise "Release" +set (DEFAULT_BUILD_TYPE "Release") if (EXISTS "${CMAKE_SOURCE_DIR}/.git") - set (default_build_type "Debug") + set (DEFAULT_BUILD_TYPE "Debug") endif () -# Set the possible values of build type for cmake-gui and command line check -set (allowed_build_types Debug Release MinSizeRel RelWithDebInfo Coverage) -set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${allowed_build_types}) - if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message (STATUS "Setting build type to '${default_build_type}' as no other was specified.") - set (CMAKE_BUILD_TYPE "${default_build_type}" CACHE + message (STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as no other was specified.") + set (CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) else (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) # Ignore capitalization when build type is selected manually and check for valid setting - string (TOLOWER ${CMAKE_BUILD_TYPE} selected_lower) - string (TOLOWER "${allowed_build_types}" build_types_lower) - if (NOT selected_lower IN_LIST build_types_lower) - message (FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE} [allowed: ${allowed_build_types}]") + string (TOLOWER ${CMAKE_BUILD_TYPE} SELECTED_LOWER) + string (TOLOWER "${ALLOWED_BUILD_TYPES}" BUILD_TYPES_LOWER) + if (NOT SELECTED_LOWER IN_LIST BUILD_TYPES_LOWER) + message (FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE} [allowed: ${ALLOWED_BUILD_TYPES}]") endif () message (STATUS "Build type is: ${CMAKE_BUILD_TYPE}") endif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) # enable warnings and disallow non-standard language +# configure the various build types here, too set (CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wno-ignored-qualifiers") set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g") -set (CMAKE_CXX_FLAGS_RELEASE "-O3 -g") # -O2 would not trade speed for size, neither O2/3 use fast-math +set (CMAKE_CXX_FLAGS_RELEASE "-O3") # -O2 would not trade speed for size, neither O2/3 use fast-math +set (CMAKE_CXX_FLAGS_MINSIZEREL "-O2") +set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g") set (CMAKE_Fortran_FLAGS "-std=legacy") -# setup coverage target -set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} --coverage") +# setup coverage build type +set (CMAKE_CXX_FLAGS_COVERAGE "-g --coverage") set (CMAKE_EXE_LINKER_FLAGS_COVERAGE "--coverage") set (CMAKE_SHARED_LINKER_FLAGS_COVERAGE "--coverage") # clang produces a lot of unecessary warnings without this: add_compile_options ("$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-nonportable-include-path>") -# COAST - interface +# COAST - interface, this requires CORSIKA7 to be installed first +# COAST will allow you to program code in CORSIKA8 and execute it inside CORSIKA7 if (WITH_COAST) message (STATUS "Compiling CORSIKA8 for the use with COAST/corsika7.") add_compile_options ("-fPIC") endif () -# generate coverage report +# targets and settings needed to generate coverage reports if (CMAKE_BUILD_TYPE STREQUAL Coverage) find_package (Perl REQUIRED) set (GCOV gcov CACHE STRING "gcov executable" FORCE) set (LCOV_BIN_DIR "${PROJECT_SOURCE_DIR}/ThirdParty/lcov/bin") # collect coverage data - add_custom_command(OUTPUT raw-coverage.info + add_custom_command ( + OUTPUT raw-coverage.info COMMAND ${CMAKE_COMMAND} -E echo "Note: you need to run ctest at least once to generate the coverage data" - COMMAND ${LCOV_BIN_DIR}/lcov --gcov-tool=${GCOV} --directory . --capture --output-file raw-coverage.info) + COMMAND ${LCOV_BIN_DIR}/lcov --gcov-tool=${GCOV} --directory . --capture --output-file raw-coverage.info + ) # remove uninteresting entries - add_custom_command(OUTPUT coverage.info + add_custom_command ( + OUTPUT coverage.info COMMAND ${LCOV_BIN_DIR}/lcov --remove raw-coverage.info "*/usr/*" --output-file coverage2.info COMMAND ${LCOV_BIN_DIR}/lcov --remove coverage2.info "*/ThirdParty/*" --output-file coverage.info COMMAND ${CMAKE_COMMAND} -E remove coverage2.info - DEPENDS raw-coverage.info) + DEPENDS raw-coverage.info + ) # generate html report - add_custom_command(OUTPUT coverage-report + add_custom_command ( + OUTPUT coverage-report COMMAND ${LCOV_BIN_DIR}/genhtml coverage.info -o coverage-report - DEPENDS coverage.info) + DEPENDS coverage.info + ) add_custom_target(coverage DEPENDS coverage-report) endif () -#add_custom_target (corsika_pre_build) -#add_custom_command (TARGET corsika_pre_build PRE_BUILD COMMAND "${PROJECT_SOURCE_DIR}/pre_compile.py") - find_package (Pythia8) # optional - find_package (Eigen3 REQUIRED) -#find_package (HDF5) # not yet needed # order of subdirectories add_subdirectory (ThirdParty) diff --git a/Framework/StackInterface/CMakeLists.txt b/Framework/StackInterface/CMakeLists.txt index 91b09a2ee22af91c289c4ae977d61e7738462872..07777e5ffb55fdc209c0ca0bdeca579b52e0ec1a 100644 --- a/Framework/StackInterface/CMakeLists.txt +++ b/Framework/StackInterface/CMakeLists.txt @@ -17,7 +17,9 @@ add_library ( INTERFACE ) -CORSIKA_COPY_HEADERS_TO_NAMESPACE (CORSIKAstackinterface ${CORSIKAstackinterface_NAMESPACE} ${CORSIKAstackinterface_HEADERS}) +CORSIKA_COPY_HEADERS_TO_NAMESPACE ( + CORSIKAstackinterface ${CORSIKAstackinterface_NAMESPACE} ${CORSIKAstackinterface_HEADERS} + ) target_include_directories ( CORSIKAstackinterface @@ -27,10 +29,8 @@ target_include_directories ( ) install ( - FILES - ${CORSIKAstackinterface_HEADERS} - DESTINATION - include/${CORSIKAstackinterface_NAMESPACE} + FILES ${CORSIKAstackinterface_HEADERS} + DESTINATION include/${CORSIKAstackinterface_NAMESPACE} ) #code testing