diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd6f0ba077e877aa7c1802aa807f9481a073c75..74c59086064789144e328c4d1bc911c410658d5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,13 @@ +# +# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu +# +# See file AUTHORS for a list of contributors. +# +# This software is distributed under the terms of the GNU General Public +# Licence version 3 (GPL Version 3). See file LICENSE for a full version of +# the license. +# + cmake_minimum_required (VERSION 3.9) #+++++++++++++++++++++++++++++ @@ -32,12 +42,6 @@ if (POLICY CMP0079) cmake_policy (SET CMP0079 NEW) endif () -#+++++++++++++++++++++++++++++ -# as long as there still are modules using it: -# -enable_language (Fortran) -set (CMAKE_Fortran_FLAGS "-std=legacy -Wfunction-elimination") - #+++++++++++++++++++++++++++++ # warn user if system is not UNIX # @@ -50,15 +54,19 @@ endif () # set (CORSIKA8_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake") set (CMAKE_MODULE_PATH "${CORSIKA8_CMAKE_DIR}" ${CMAKE_MODULE_PATH}) -include (CorsikaUtilities) # extra cmake function set (CMAKE_VERBOSE_MAKEFILE OFF) # this can be done with `make VERBOSE=1` # ignore many irrelevant Up-to-date messages during install set (CMAKE_INSTALL_MESSAGE LAZY) #+++++++++++++++++++++++++++++ -# Setup hardware and infrastructure dependent defines +# Extra cmake functions for registering and running tests +# +include (corsikaUtilities) # extra cmake functions + +#+++++++++++++++++++++++++++++ +# Setup hardware and infrastructure dependent defines, and general settings # -include (CorsikaDefines) +include (corsikaDefines) #+++++++++++++++++++++++++++++ # check if compiler is C++17 compliant @@ -81,50 +89,14 @@ set (CMAKE_CXX_EXTENSIONS OFF) # debug: O0, relwithdebinfo: 02, release: O3, minsizerel: Os (all defaults) set (CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wno-ignored-qualifiers") if (CORSIKA_SCL_CXX) - add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) + add_definitions (-D_GLIBCXX_USE_CXX11_ABI=0) endif() -set (DEFAULT_BUILD_TYPE "Release") # 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> ) -#+++++++++++++++++++++++++++++ -# Build types settings -# -# 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") -# set a flag to inform code that we are in debug mode -set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") - -#+++++++++++++++++++++++++++++ -# Build type selection -# -# 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 -# 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") -endif () -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 - 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}]") - endif () - message (STATUS "Build type is: ${CMAKE_BUILD_TYPE}") -endif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) #+++++++++++++++++++++++++++++ # Setup external dependencies. @@ -314,6 +286,13 @@ configure_package_config_file ( INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX} ) +# corsikaDefines for build tree +configure_package_config_file ( + cmake/corsikaDefines.cmake + ${PROJECT_BINARY_DIR}/corsikaDefines.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX} + ) + # config for install tree # overwrite with install location (if it was build as part of corsika) set (Pythia8_INCDIR ${Pythia8_INCDIR_INSTALL}) @@ -329,6 +308,7 @@ install ( ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake ${CMAKE_BINARY_DIR}/conaninfo.txt ${CMAKE_BINARY_DIR}/corsikaConfig.cmake + ${CMAKE_BINARY_DIR}/corsikaDefines.cmake ${CMAKE_BINARY_DIR}/corsikaConfigVersion.cmake DESTINATION lib/cmake/corsika ) diff --git a/cmake/CorsikaDefines.cmake b/cmake/CorsikaDefines.cmake deleted file mode 100644 index 2019ce2f906f9025e2181a0c9eb624e99f9ca44e..0000000000000000000000000000000000000000 --- a/cmake/CorsikaDefines.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# -# Floating point exception support - select implementation to use -# -include (CheckIncludeFileCXX) -CHECK_INCLUDE_FILE_CXX ("fenv.h" HAS_FEENABLEEXCEPT) -if (HAS_FEENABLEEXCEPT) # FLOATING_POINT_ENVIRONMENT - set (CORSIKA_HAS_FEENABLEEXCEPT 1) - set_property (DIRECTORY ${CMAKE_HOME_DIRECTORY} APPEND PROPERTY COMPILE_DEFINITIONS "HAS_FEENABLEEXCEPT") -endif () - - -# -# General OS Detection -# -if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set (CORSIKA_OS_WINDOWS TRUE) - set (CORSIKA_OS "Windows") -elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set (CORSIKA_OS_LINUX TRUE) - set (CORSIKA_OS "Linux") - # check for RedHat/CentOS compiler from the software collections (scl) - string (FIND ${CMAKE_CXX_COMPILER} "/opt/rh/devtoolset-" index) - if (${index} EQUAL 0) - set (CORSIKA_SCL_CXX TRUE) - endif () -elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set (CORSIKA_OS_MAC TRUE) - set (CORSIKA_OS "Mac") -endif () diff --git a/cmake/FindPhysUnits.cmake b/cmake/FindPhysUnits.cmake index 321ec043e882c5c98d611a6daf5c23438e8b4c81..20fa1aaa4928ec0f37ce8ee573c7a4659756f98b 100644 --- a/cmake/FindPhysUnits.cmake +++ b/cmake/FindPhysUnits.cmake @@ -1,3 +1,13 @@ +# +# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu +# +# See file AUTHORS for a list of contributors. +# +# This software is distributed under the terms of the GNU General Public +# Licence version 3 (GPL Version 3). See file LICENSE for a full version of +# the license. +# + add_library (PhysUnits INTERFACE) target_compile_options (PhysUnits diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake index 9a6705c4840e57d3c7940289be5e498ad0fcce15..62825ee4c3d14139ca371c9dd8d8f028da25181e 100644 --- a/cmake/FindSphinx.cmake +++ b/cmake/FindSphinx.cmake @@ -1,3 +1,13 @@ +# +# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu +# +# See file AUTHORS for a list of contributors. +# +# This software is distributed under the terms of the GNU General Public +# Licence version 3 (GPL Version 3). See file LICENSE for a full version of +# the license. +# + # Look for an executable called sphinx-build find_program (SPHINX_EXECUTABLE NAMES sphinx-build diff --git a/cmake/corsikaConfig.cmake.in b/cmake/corsikaConfig.cmake.in index 546d5141d2c467cf7293bddf4cabef6fa28d481f..3a833b71c2ad78dcd0d8af5b194bd004774407f6 100644 --- a/cmake/corsikaConfig.cmake.in +++ b/cmake/corsikaConfig.cmake.in @@ -1,37 +1,27 @@ +# +# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu +# +# See file AUTHORS for a list of contributors. +# +# This software is distributed under the terms of the GNU General Public +# Licence version 3 (GPL Version 3). See file LICENSE for a full version of +# the license. +# + set (CORSIKA8_VERSION @c8_version@) @PACKAGE_INIT@ +#+++++++++++++++++++++++++++++ +# Setup hardware and infrastructure dependent defines and other setting +# +include (${CMAKE_CURRENT_LIST_DIR}/corsikaDefines.cmake) + #+++++++++++++++++++++++++++ # Options # option (WITH_HISTORY "Flag to switch on/off HISTORY" ON) - - -#+++++++++++++++++++++++++++++ -# Build types settings -# -# 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") -# set a flag to inform code that we are in debug mode -set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") -set (ALLOWED_BUILD_TYPES Debug Release MinSizeRel RelWithDebInfo Coverage) -set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${ALLOWED_BUILD_TYPES}) -set (DEFAULT_BUILD_TYPE "Release") -if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set (CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE - STRING "Choose the type of build." FORCE) -endif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) -#+++++++++++++++++++++++++++++ -# as long as there still are modules using it: -# -enable_language (Fortran) -set (CMAKE_Fortran_FLAGS "-std=legacy -Wfunction-elimination") - - #++++++++++++++++++++++++++++ # General config and flags # diff --git a/cmake/corsikaDefines.cmake b/cmake/corsikaDefines.cmake new file mode 100644 index 0000000000000000000000000000000000000000..60cf7da9a930a6bb7b39e35678e8b7064c411f42 --- /dev/null +++ b/cmake/corsikaDefines.cmake @@ -0,0 +1,86 @@ +# +# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu +# +# See file AUTHORS for a list of contributors. +# +# This software is distributed under the terms of the GNU General Public +# Licence version 3 (GPL Version 3). See file LICENSE for a full version of +# the license. +# + + +#+++++++++++++++++++++++++++++ +# as long as there still are modules using it: +# +enable_language (Fortran) +set (CMAKE_Fortran_FLAGS "-std=legacy -Wfunction-elimination") + + +#+++++++++++++++++++++++++++++ +# Build types settings +# +# 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") +# set a flag to inform code that we are in debug mode +set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") + + +#+++++++++++++++++++++++++++++ +# Build type selection +# +# 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 (DEFAULT_BUILD_TYPE "Release") +if (EXISTS "${CMAKE_SOURCE_DIR}/.git") + set (DEFAULT_BUILD_TYPE "Debug") +endif () + +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 + 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}]") + endif () + message (STATUS "Build type is: ${CMAKE_BUILD_TYPE}") +endif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + + + +# +# Floating point exception support - select implementation to use +# +include (CheckIncludeFileCXX) +CHECK_INCLUDE_FILE_CXX ("fenv.h" HAS_FEENABLEEXCEPT) +if (HAS_FEENABLEEXCEPT) # FLOATING_POINT_ENVIRONMENT + set (CORSIKA_HAS_FEENABLEEXCEPT 1) + set_property (DIRECTORY ${CMAKE_HOME_DIRECTORY} APPEND PROPERTY COMPILE_DEFINITIONS "CORSIKA_HAS_FEENABLEEXCEPT") +endif () + + +# +# General OS Detection +# +if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set (CORSIKA_OS_WINDOWS TRUE) + set (CORSIKA_OS "Windows") +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set (CORSIKA_OS_LINUX TRUE) + set (CORSIKA_OS "Linux") + # check for RedHat/CentOS compiler from the software collections (scl) + string (FIND ${CMAKE_CXX_COMPILER} "/opt/rh/devtoolset-" index) + if (${index} EQUAL 0) + set (CORSIKA_SCL_CXX TRUE) + endif () +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set (CORSIKA_OS_MAC TRUE) + set (CORSIKA_OS "Mac") +endif () diff --git a/cmake/CorsikaUtilities.cmake b/cmake/corsikaUtilities.cmake similarity index 100% rename from cmake/CorsikaUtilities.cmake rename to cmake/corsikaUtilities.cmake diff --git a/corsika/detail/media/ShowerAxis.inl b/corsika/detail/media/ShowerAxis.inl index a42989e9222f0c4ec6131d42fe37110ff62faf5a..4cabe21b5a3e4cee53cfedcaf6b211f9b93a47fa 100644 --- a/corsika/detail/media/ShowerAxis.inl +++ b/corsika/detail/media/ShowerAxis.inl @@ -84,6 +84,7 @@ namespace corsika { l / max_length_); throw std::runtime_error(err.c_str()); } + return getMaximumX(); } CORSIKA_LOG_TRACE("showerAxis::X frac={}, fractionalBin={}, lower={}, upper={}", fraction, fractionalBin, lower, upper); diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8cd42babe67261c0f17e52805e67bfceb8a09ab7..3240a632cb15c390454e99e0515c52f7945336e7 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,7 +7,7 @@ set (CMAKE_VERBOSE_MAKEFILE OFF) # this can be changed with `make VERBOSE=1` find_package (corsika CONFIG REQUIRED) # this is only for CORSIKA_REGISTER_EXAMPLE -include ("${CMAKE_CURRENT_SOURCE_DIR}/CMakeHelper.cmake") +include ("${CMAKE_CURRENT_SOURCE_DIR}/corsikaExamples.cmake") add_executable (helix_example helix_example.cpp) target_link_libraries (helix_example CORSIKA8::CORSIKA8) diff --git a/examples/cascade_example.cpp b/examples/cascade_example.cpp index eb0938d9fe08e93ac3a3f9d972362d9c58a0ef48..b9195515c189d992adaedba6f59cf99496ab44e5 100644 --- a/examples/cascade_example.cpp +++ b/examples/cascade_example.cpp @@ -54,7 +54,6 @@ using namespace std; // int main() { - corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); logging::set_level(logging::level::trace); std::cout << "cascade_example" << std::endl; diff --git a/examples/CMakeHelper.cmake b/examples/corsikaExamples.cmake similarity index 100% rename from examples/CMakeHelper.cmake rename to examples/corsikaExamples.cmake diff --git a/tests/framework/testCombinedStack.cpp b/tests/framework/testCombinedStack.cpp index 7d01f3fcd3139507c41617a2fd276ddfedb46138..1f76fafc21927832063f5271fb8ed26443dffa50 100644 --- a/tests/framework/testCombinedStack.cpp +++ b/tests/framework/testCombinedStack.cpp @@ -218,6 +218,16 @@ TEST_CASE("Combined Stack", "[stack]") { CHECK(s.getEntries() == 0); CHECK(s.isEmpty()); } + + SECTION("exceptions") { + StackTest s; + auto p1 = s.addParticle(std::tuple{9.9}); + auto p2 = s.addParticle(std::tuple{9.9}); + ++p2; + CHECK_THROWS(s.copy(p1, p2)); + CHECK_THROWS(s.swap(p1, p2)); + CHECK(s.getSize() == 2); + } } //////////////////////////////////////////////////////////// @@ -288,7 +298,6 @@ using StackTest2 = CombinedStack<typename StackTest::stack_implementation_type, TEST_CASE("Combined Stack - multi", "[stack]") { logging::set_level(logging::level::info); - corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); SECTION("create secondaries") {