diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2fc025461b364b42cffc24acba8e145bdb0e6e4f..669dfffd58b9b83fbc2e568751c947a9609ca8f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,7 @@ variables: ASAN_OPTIONS: "detect_leaks=0:detect_stack_use_after_return=1" # location of AirShowerPhysics/corsika-data CORSIKA_DATA: "${CI_PROJECT_DIR}/modules/data" # the git submodule + corsika_DIR: "${CI_PROJECT_DIR}/build/install" # for cmake to find corsikaConfig.cmake # _alternatively_ corsika-data can be downloaded as submodule: GIT_SUBMODULE_STRATEGY: normal # none: we get the submodules in before_script, # normal: get submodules automatically @@ -92,7 +93,7 @@ check-clang-format: script: - mkdir -p build - cd build - - cmake .. -DCMAKE_BUILD_TYPE=Debug -DUSE_PYTHIA8_C8=C8 + - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8 rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG @@ -279,56 +280,6 @@ build_test-clang-8: -####### EXAMPLE (only manual) ############## - -########################################################## -# generic example template job -# normal pipeline for each commit -.example: - stage: example - tags: - - corsika - script: - - cd build - - set -o pipefail - - make -j4 run_examples | gzip -v -9 > examples.log.gz - rules: - - if: $CI_MERGE_REQUEST_ID - when: manual - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH - when: manual - allow_failure: true - artifacts: - when: always - expire_in: 3 days - paths: - - ${CI_PROJECT_DIR}/build/examples.log.gz - cache: - paths: - - ${CI_PROJECT_DIR}/build/ - untracked: true - policy: pull - -# example for gcc -example-u-18_04: - extends: .example - image: corsika/devel:u-18.04 - dependencies: - - build-u-18_04 - cache: - key: "${CI_COMMIT_REF_SLUG}-gcc" - -# example for clang -example-clang-8: - extends: .example - image: corsika/devel:clang-8 - dependencies: - - build-clang-8 - cache: - key: "${CI_COMMIT_REF_SLUG}-clang" - ####### BUILD-TEST-EXAMPLE (only non-Draft) ############## @@ -344,7 +295,12 @@ example-clang-8: - cd build - cmake --build . -- -j4 - set -o pipefail - - ctest -j4 + - ctest -j4 + - make install + - mkdir -p build_examples + - cd build_examples + - cmake ../install/share/corsika/examples + - make -j4 - make -j4 run_examples | gzip -v -9 > examples.log.gz rules: - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/' @@ -362,7 +318,7 @@ example-clang-8: junit: - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml paths: - - ${CI_PROJECT_DIR}/build/examples.log.gz + - ${CI_PROJECT_DIR}/build/build_examples/examples.log.gz cache: paths: - ${CI_PROJECT_DIR}/build/ @@ -450,10 +406,15 @@ install-clang-8: - corsika script: - cd build - - cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_PYTHIA8_C8=C8 + - cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_Pythia8_C8=C8 - cmake --build . -- -j4 - set -o pipefail - - ctest -j4 + - ctest -j4 + - make install + - mkdir -p build_examples + - cd build_examples + - cmake ../install/share/corsika/examples + - make -j4 - make -j4 run_examples | gzip -v -9 > examples.log.gz rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /Ready for code review/' # run on merge requests, if label 'Ready for code review' is set @@ -478,7 +439,7 @@ install-clang-8: junit: - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml paths: - - ${CI_PROJECT_DIR}/build/examples.log.gz + - ${CI_PROJECT_DIR}/build/build_examples/examples.log.gz # release for gcc release-full-u-18_04: @@ -513,7 +474,7 @@ coverage: - corsika script: - cd build - - cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_PYTHIA8_C8=C8 + - cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_Pythia8_C8=C8 - cmake --build . -- -j4 - ctest -j4 - cmake --build . --target coverage @@ -575,5 +536,3 @@ sanity: untracked: true policy: pull key: "${CI_COMMIT_REF_SLUG}-gcc" - - diff --git a/CMakeLists.txt b/CMakeLists.txt index c8a4cb765ec196e42197e9a802f5dbfa0959ad7d..6f509f464f621c5fe2fcf10f5496e05f823ff58e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,16 @@ cmake_minimum_required (VERSION 3.9) +#+++++++++++++++++++++++++++++ +# project name +# +set (c8_version 8.0.0) +project ( + corsika + VERSION ${c8_version} + DESCRIPTION "CORSIKA C++ project (alpha status)" + LANGUAGES CXX + ) + #+++++++++++++++++++++++++++++ # prevent in-source builds and give warning message # @@ -10,15 +21,16 @@ if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") You must delete them, or cmake will refuse to work.") endif () -#+++++++++++++++++++++++++++++ -# project name +#++++++++++++++++++++++++++++ +# cmake version-specific settings # -project ( - corsika - VERSION 8.0.0 - DESCRIPTION "CORSIKA C++ project (alpha status)" - LANGUAGES CXX - ) +# https://cmake.org/cmake/help/latest/policy/CMP0079.html +if (${CMAKE_VERSION} VERSION_GREATER "3.13.0") + cmake_policy (SET CMP0079 NEW) +endif () +if (POLICY CMP0079) + cmake_policy (SET CMP0079 NEW) +endif () #+++++++++++++++++++++++++++++ # as long as there still are modules using it: @@ -37,7 +49,7 @@ endif () # cmake path dir, and cmake config # set (CORSIKA8_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake") -set (CMAKE_MODULE_PATH "${CORSIKA8_CMAKE_DIR}" ${CMAKE_MODULE_PATH}) +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 @@ -46,7 +58,7 @@ set (CMAKE_INSTALL_MESSAGE LAZY) #+++++++++++++++++++++++++++++ # Setup hardware and infrastructure dependent defines # -include(CorsikaDefines) +include (CorsikaDefines) #+++++++++++++++++++++++++++++ # check if compiler is C++17 compliant @@ -68,7 +80,6 @@ set (CMAKE_CXX_EXTENSIONS OFF) # FYI: optimizer flags: -O2 would not trade speed for size, neither O2/3 use fast-math # debug: O0, relwithdebinfo: 02, release: O3, minsizerel: Os (all defaults) set (CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wno-ignored-qualifiers") -set (CMAKE_Fortran_FLAGS "-std=legacy -Wfunction-elimination") set (DEFAULT_BUILD_TYPE "Release") # clang produces a lot of unecessary warnings without this: @@ -149,7 +160,7 @@ if (CMAKE_BUILD_TYPE STREQUAL Coverage) add_custom_command ( OUTPUT coverage.info COMMAND ${LCOV_BIN_DIR}/lcov -q --remove raw-coverage.info "*/usr/*" "/usr/*" --output-file coverage2.info - COMMAND ${LCOV_BIN_DIR}/lcov --remove coverage2.info "*/externals/*" "*/tests/*" "*/sibyll2.3d.cpp" "*/.conan/*" "*/include/Pythia8/*" "${CMAKE_CURRENT_SOURCE_DIR}/modules/*" "${CMAKE_CURRENT_BINARY_DIR}/modules/*" --output-file coverage.info + COMMAND ${LCOV_BIN_DIR}/lcov --remove coverage2.info "*/externals/*" "*/tests/*" "*/sibyll2.3d.cpp" "*/.conan/*" "*/include/Pythia8/*" "${CMAKE_SOURCE_DIR}/modules/*" "${CMAKE_BINARY_DIR}/modules/*" --output-file coverage.info COMMAND ${CMAKE_COMMAND} -E remove coverage2.info DEPENDS raw-coverage.info ) @@ -175,7 +186,7 @@ set (CTEST_CUSTOM_COVERAGE_EXCLUDE "./tests/" "./examples/" "./modules/" "test*. # include this test only if NOT run on gitlab-ci; On CI this is a dedicated job: if (NOT DEFINED ENV{CI}) # add call to ./do-copyright.py to run as unit-test-case - add_test (NAME copyright_notices COMMAND ./do-copyright.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_test (NAME copyright_notices COMMAND ./do-copyright.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) endif (NOT DEFINED ENV{CI}) #+++++++++++++++++++++++++++++ @@ -190,18 +201,34 @@ option (WITH_HISTORY "Flag to switch on/off HISTORY" ON) set (Python_ADDITIONAL_VERSIONS 3) find_package (PythonInterp 3 REQUIRED) +#+++++++++++++++++++++++++++++++ +# exporting of CMake targets +# +include (CMakePackageConfigHelpers) + +# list of targets that will be INSTALLed and EXPORTed +# Important: all those targets must be individually INSTALLed with "EXPORT CORSIKA8PublicTargets" +set (public_CORSIKA8_targets CORSIKA8) + #+++++++++++++++++++++++++++++ # CORSIKA8 # add_library (CORSIKA8 INTERFACE) +set_target_properties ( + CORSIKA8 + PROPERTIES + INTERFACE_CORSIKA8_MAJOR_VERSION 0 + COMPATIBLE_INTERFACE_STRING CORSIKA8_MAJOR_VERSION + ) +# target_include_directories ( CORSIKA8 INTERFACE - $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> - $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> - $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}> - ) + $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}> + $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}> + $<INSTALL_INTERFACE:include> + ) # since CORSIKA8 is a header only library we must specify all link dependencies here: target_link_libraries ( CORSIKA8 @@ -217,22 +244,21 @@ add_subdirectory (src) add_subdirectory (documentation) #+++++++++++++++++++++++++++++ -# =~~~~~~~~~~~~~~~~~~~~~~~~~= # = Add of subdirectories = -# =~~~~~~~~~~~~~~~~~~~~~~~~~= +# #+++++++++++++++++++++++++++++ # modules # set (CORSIKA_DATA_WITH_TEST ON) # we want to run the corsika-data unit test add_subdirectory (modules/data) # this is corsika-data (submodule) -add_subdirectory (modules/pythia) +add_subdirectory (modules/pythia8) add_subdirectory (modules/sibyll) add_subdirectory (modules/qgsjetII) add_subdirectory (modules/urqmd) add_subdirectory (modules/conex) # -# we really need a better proposal CMakeList.txt files: +# we really need a better proposal CMakeList.txt file: set (ADD_PYTHON OFF) file (READ modules/CMakeLists_PROPOSAL.txt overwrite_CMakeLists_PROPOSAL_txt) file (WRITE modules/proposal/CMakeLists.txt ${overwrite_CMakeLists_PROPOSAL_txt}) @@ -245,9 +271,79 @@ target_link_libraries (CORSIKA8 INTERFACE PROPOSAL) add_subdirectory (tests) #+++++++++++++++++++++++++++++++ +# installation +# +install ( + TARGETS CORSIKA8 + EXPORT CORSIKA8PublicTargets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX} + ) + +# +# header only part +# +install (DIRECTORY corsika DESTINATION include) + +write_basic_package_version_file ( + ${PROJECT_BINARY_DIR}/corsikaConfigVersion.cmake + VERSION ${c8_version} + COMPATIBILITY SameMajorVersion + ) + +# export targets in build tree +export ( + EXPORT CORSIKA8PublicTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/corsikaTargets.cmake" + NAMESPACE CORSIKA8:: + ) + +# export targets in install tree +install ( + EXPORT CORSIKA8PublicTargets + FILE corsikaTargets.cmake + NAMESPACE CORSIKA8:: + DESTINATION lib/cmake/corsika + ) + +# config for build tree +configure_package_config_file ( + cmake/corsikaConfig.cmake.in + ${PROJECT_BINARY_DIR}/corsikaConfig.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}) +set (Pythia8_LIBDIR ${Pythia8_LIBDIR_INSTALL}) +configure_package_config_file ( + cmake/corsikaConfig.cmake.in + ${PROJECT_BINARY_DIR}/cmake/corsikaConfig.cmake + INSTALL_DESTINATION ${PROJECT_BINARY_DIR}/do_not_need_this + ) + +install ( + FILES + ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake + ${CMAKE_BINARY_DIR}/conaninfo.txt + ${CMAKE_BINARY_DIR}/corsikaConfig.cmake + ${CMAKE_BINARY_DIR}/corsikaConfigVersion.cmake + DESTINATION lib/cmake/corsika + ) + +# # examples -# -add_subdirectory (examples) +# +install (DIRECTORY examples DESTINATION share/corsika) + +# +# tools +# +install (DIRECTORY tools DESTINATION share/corsika) + + + + #+++++++++++++++++++++++++++++++ # diff --git a/cmake/CorsikaDefines.cmake b/cmake/CorsikaDefines.cmake index f2b08a67b68f9b92a0a809e01cf38ab5496611b0..30b8fe33cf83982d8769696af86092f371ad3747 100644 --- a/cmake/CorsikaDefines.cmake +++ b/cmake/CorsikaDefines.cmake @@ -1,11 +1,11 @@ # # Floating point exception support - select implementation to use # -include(CheckIncludeFileCXX) -CHECK_INCLUDE_FILE_CXX("fenv.h" HAS_FEENABLEEXCEPT) +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") + set_property (DIRECTORY ${CMAKE_HOME_DIRECTORY} APPEND PROPERTY COMPILE_DEFINITIONS "HAS_FEENABLEEXCEPT") endif () @@ -13,12 +13,12 @@ endif () # General OS Detection # if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set(CORSIKA_OS_WINDOWS TRUE) + set (CORSIKA_OS_WINDOWS TRUE) set (CORSIKA_OS "Windows") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(CORSIKA_OS_LINUX TRUE) + set (CORSIKA_OS_LINUX TRUE) set (CORSIKA_OS "Linux") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(CORSIKA_OS_MAC TRUE) + set (CORSIKA_OS_MAC TRUE) set (CORSIKA_OS "Mac") -endif() \ No newline at end of file +endif () diff --git a/cmake/CorsikaUtilities.cmake b/cmake/CorsikaUtilities.cmake index c71e9bea31a13a80e195552f671ac89963af3759..cf8f1ef681a13f6545b613966f9f47f576e5d918 100644 --- a/cmake/CorsikaUtilities.cmake +++ b/cmake/CorsikaUtilities.cmake @@ -68,55 +68,3 @@ function (CORSIKA_ADD_TEST) endif () add_test (NAME ${name} COMMAND ${name} -o ${PROJECT_BINARY_DIR}/test_outputs/junit-${name}.xml -s -r junit) endfunction (CORSIKA_ADD_TEST) - - -################################################# -# -# central macro to register an examples in cmake -# -# Examples can be globally executed by 'make run_examples' -# -# 1) Simple use: -# Pass the name of the source.cc file as the first -# argument, without the ".cc" extention. -# -# Example: CORSIKA_REGISTER_EXAMPLE (doSomething) -# -# The TARGET doSomething must already exists, -# i.e. typically via add_executable (doSomething src.cc). -# -# Example: CORSIKA_ADD_EXAMPLE (example_one -# RUN_OPTION "extra command line options" -# ) -# -# In all cases, you can further customize the target with -# target_link_libraries(example_one ...) and so on. -# -function (CORSIKA_REGISTER_EXAMPLE) - cmake_parse_arguments (PARSE_ARGV 1 C8_EXAMPLE "" "" "RUN_OPTIONS") - set (name ${ARGV0}) - - if (NOT C8_EXAMPLE_RUN_OPTIONS) - set (run_options "") - else () - set (run_options ${C8_EXAMPLE_RUN_OPTIONS}) - endif () - - target_compile_options (${name} PRIVATE -g) # do not skip asserts - file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/example_outputs/) - if (TARGET run_examples) - else () - add_custom_target (run_examples) - endif () - add_dependencies (run_examples ${name}) - # just run the command as-is - set (CMD ${CMAKE_BINARY_DIR}/bin/${name} ${run_options}) - add_custom_command (TARGET run_examples - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E echo "" - COMMAND ${CMAKE_COMMAND} -E echo "**************************************" - COMMAND ${CMAKE_COMMAND} -E echo "***** running example: ${name} " ${run_options} VERBATIM - COMMAND ${CMD} VERBATIM - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/example_outputs) - install (TARGETS ${name} DESTINATION share/examples) -endfunction (CORSIKA_REGISTER_EXAMPLE) diff --git a/cmake/FindPythia8.cmake b/cmake/FindPythia8.cmake index 0818c4f1be66834cade34eb4e6e146f269d76c0d..cbd3e75eed41ff3c8dbeae4ceeab55241f111abe 100644 --- a/cmake/FindPythia8.cmake +++ b/cmake/FindPythia8.cmake @@ -68,6 +68,11 @@ find_file (Pythia8_Pythia_h_LOC PATH_SUFFIXES include/Pythia8 DOC "The location of the Pythia8/Pythia.h script" REQUIRED) + +if ("${Pythia8_Pythia_h_LOC}" STREQUAL "Pythia8_Pythia_h_LOC-NOTFOUND") + message (FATAL_ERROR "Did not find SYSTEM-level Pythia8 in: \"${_SEARCH_Pythia8_}\"") +endif () + string (REPLACE "/include/Pythia8/Pythia.h" "" Pythia8_DIR ${Pythia8_Pythia_h_LOC}) set (Pythia8_CONFIG ${Pythia8_DIR}/bin/pythia-config) diff --git a/cmake/corsikaConfig.cmake.in b/cmake/corsikaConfig.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..4bf1338b2ba78645d668e1c1468b537ec566480b --- /dev/null +++ b/cmake/corsikaConfig.cmake.in @@ -0,0 +1,39 @@ +set (CORSIKA8_VERSION @c8_version@) + +@PACKAGE_INIT@ + +#++++++++++++++++++++++++++++ +# General config and flags +# +set (CMAKE_CXX_STANDARD @CMAKE_CXX_STANDARD@) +set (CMAKE_CXX_EXTENSIONS @CMAKE_CXX_EXTENSIONS@) +set (COMPILE_OPTIONS @COMPILE_OPTIONS@) +set (CMAKE_VERBOSE_MAKEFILE @CMAKE_VERBOSE_MAKEFILE@) + +#+++++++++++++++++++++++++++++ +# Setup external dependencies via conan +# +include (${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo.cmake) +conan_basic_setup (TARGETS) + +#+++++++++++++++++++++++++++++ +# Import Pythia8 +# since we always import pythia (ExternalProject_Add) we have to +# import here, too. +# +add_library (C8::ext::pythia8 STATIC IMPORTED GLOBAL) +set_target_properties ( + C8::ext::pythia8 PROPERTIES + IMPORTED_LOCATION @Pythia8_LIBDIR@/libpythia8.a + IMPORTED_LINK_INTERFACE_LIBRARIES dl + INTERFACE_INCLUDE_DIRECTORIES @Pythia8_INCDIR@ + ) +set (Pythia8_FOUND @Pythia8_FOUND@) +message (STATUS "Pythia8 at: @Pythia8_PREFIX@") + + +#++++++++++++++++++++++++++++++ +# import CORSIKA8 +# +include ("${CMAKE_CURRENT_LIST_DIR}/corsikaTargets.cmake") +check_required_components (corsika) diff --git a/corsika/framework/geometry/Point.hpp b/corsika/framework/geometry/Point.hpp index 82d783212b5f2309b1936b465c86434f5674e784..b06a68bdebc236f2520007da1031bb76491f6a70 100644 --- a/corsika/framework/geometry/Point.hpp +++ b/corsika/framework/geometry/Point.hpp @@ -52,7 +52,7 @@ namespace corsika { inline QuantityVector<length_d>& getCoordinates(CoordinateSystemPtr const& pCS); /** - * \defgroup access coordinate components + * \name access coordinate components * \{ * * Note, if you access components in a different CoordinateSystem diff --git a/corsika/modules/pythia8/Pythia8.hpp b/corsika/modules/pythia8/Pythia8.hpp index 6e8f80e8955b813d3c9bfc30c80a781b9dba625d..c74aa8d0dd2f16b9a2fd566b27fb74a2503cb089 100644 --- a/corsika/modules/pythia8/Pythia8.hpp +++ b/corsika/modules/pythia8/Pythia8.hpp @@ -9,7 +9,7 @@ #pragma once // the location of the "xmldoc" pythia directory (data files, config) -#include <Pythia8ConfigurationDirectory.hpp> +#include <corsika/modules/pythia8/Pythia8ConfigurationDirectory.hpp> // the main pythia include #include <Pythia8/Pythia.h> diff --git a/corsika/stack/history/CMakeLists.txt b/corsika/stack/history/CMakeLists.txt deleted file mode 100644 index 2a47b86189bef946269e8f2815a51b2cfcf171f6..0000000000000000000000000000000000000000 --- a/corsika/stack/history/CMakeLists.txt +++ /dev/null @@ -1,69 +0,0 @@ -set ( - HISTORY_HEADERS - EventType.hpp - Event.hpp - HistorySecondaryProducer.hpp - HistoryObservationPlane.hpp - HistoryStackExtension.hpp - SecondaryParticle.hpp - ) - -set ( - HISTORY_NAMESPACE - corsika/stack/history - ) - -if (WITH_HISTORY) - set ( - HISTORY_SOURCES - HistoryObservationPlane.cpp - ) - add_library (CORSIKAhistory STATIC ${HISTORY_SOURCES}) - set (IS_INTERFACE "") -else (WITH_HISTORY) - add_library (CORSIKAhistory INTERFACE) - set (IS_INTERFACE "INTERFACE") -endif (WITH_HISTORY) - -CORSIKA_COPY_HEADERS_TO_NAMESPACE (CORSIKAhistory ${HISTORY_NAMESPACE} ${HISTORY_HEADERS}) - -target_link_libraries ( - CORSIKAhistory - ${IS_INTERFACE} - CORSIKAparticles - CORSIKAgeometry - CORSIKAprocesssequence # for HistoryObservationPlane - CORSIKAsetup # for HistoryObservationPlane - CORSIKAlogging - SuperStupidStack - NuclearStackExtension # for testHistoryView.cc - C8::ext::boost # for HistoryObservationPlane - ) - -target_include_directories ( - CORSIKAhistory - INTERFACE - $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> - $<INSTALL_INTERFACE:include/include> - ) - -install ( - FILES ${HISTORY_HEADERS} - DESTINATION include/${HISTORY_NAMESPACE} - ) - -# ---------------- -# code unit testing -CORSIKA_ADD_TEST(testHistoryStack) -target_link_libraries ( - testHistoryStack - CORSIKAhistory - CORSIKAtesting - DummyStack - ) -CORSIKA_ADD_TEST(testHistoryView) -target_link_libraries ( - testHistoryView - CORSIKAhistory - CORSIKAtesting - ) diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt index b3511f84ddbc9ccdce365479323f4d5f7d798596..e62d3c71db4fb27081f910d7623a53eadf85c7bf 100644 --- a/documentation/CMakeLists.txt +++ b/documentation/CMakeLists.txt @@ -3,7 +3,7 @@ find_package (Doxygen OPTIONAL_COMPONENTS dot mscgen dia) if (DOXYGEN_FOUND) if (NOT DOXYGEN_DOT_EXECUTABLE) message (FATAL_ERROR "Found doxygen but not 'dot' command, please install graphviz or set DOXYGEN_DOT_EXECUTABLE") - endif() + endif (NOT DOXYGEN_DOT_EXECUTABLE) set (DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) set (DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) @@ -17,14 +17,15 @@ if (DOXYGEN_FOUND) COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" - VERBATIM) + VERBATIM + ) - add_custom_command(TARGET doxygen POST_BUILD + add_custom_command (TARGET doxygen POST_BUILD COMMAND cd ${CMAKE_CURRENT_BINARY_DIR}/latex; pdflatex refman.tex ) - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc OPTIONAL) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.pdf DESTINATION share/doc OPTIONAL) + install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc OPTIONAL) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.pdf DESTINATION share/doc OPTIONAL) else (DOXYGEN_FOUND) diff --git a/examples/CMakeHelper.cmake b/examples/CMakeHelper.cmake new file mode 100644 index 0000000000000000000000000000000000000000..398863c5c72e99f7e46b5ef142d56a534b7dc67f --- /dev/null +++ b/examples/CMakeHelper.cmake @@ -0,0 +1,50 @@ +################################################# +# +# central macro to register an examples in cmake +# +# Examples can be globally executed by 'make run_examples' +# +# 1) Simple use: +# Pass the name of the source.cc file as the first +# argument, without the ".cc" extention. +# +# Example: CORSIKA_REGISTER_EXAMPLE (doSomething) +# +# The TARGET doSomething must already exists, +# i.e. typically via add_executable (doSomething src.cc). +# +# Example: CORSIKA_ADD_EXAMPLE (example_one +# RUN_OPTION "extra command line options" +# ) +# +# In all cases, you can further customize the target with +# target_link_libraries (example_one ...) and so on. +# +function (CORSIKA_REGISTER_EXAMPLE) + cmake_parse_arguments (PARSE_ARGV 1 C8_EXAMPLE "" "" "RUN_OPTIONS") + set (name ${ARGV0}) + + if (NOT C8_EXAMPLE_RUN_OPTIONS) + set (run_options "") + else () + set (run_options ${C8_EXAMPLE_RUN_OPTIONS}) + endif () + + target_compile_options (${name} PRIVATE -g) # do not skip asserts + file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/example_outputs/) + if (TARGET run_examples) + else () + add_custom_target (run_examples) + endif () + add_dependencies (run_examples ${name}) + # just run the command as-is + set (CMD ${CMAKE_CURRENT_BINARY_DIR}/bin/${name} ${run_options}) + add_custom_command (TARGET run_examples + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "" + COMMAND ${CMAKE_COMMAND} -E echo "**************************************" + COMMAND ${CMAKE_COMMAND} -E echo "***** running example: ${name} " ${run_options} VERBATIM + COMMAND ${CMD} VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/example_outputs) + install (TARGETS ${name} DESTINATION share/examples) +endfunction (CORSIKA_REGISTER_EXAMPLE) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a9a16a6e7f1d2a66020f709a26f4c4488d1ab2c4..4b9c6d55fc9e91202568b46ad79194fecda4c590 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,52 +1,58 @@ +cmake_minimum_required (VERSION 3.9) + +project (CORSIKA8_examples) +set (CMAKE_VERBOSE_MAKEFILE OFF) # this can be changed with `make VERBOSE=1` + +# this is enough to use CORSIKA8 +find_package (corsika CONFIG REQUIRED) + +# this is only for CORSIKA_REGISTER_EXAMPLE +include ("${CMAKE_CURRENT_SOURCE_DIR}/CMakeHelper.cmake") + add_executable (helix_example helix_example.cpp) -target_link_libraries (helix_example CORSIKA8) +target_link_libraries (helix_example CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (helix_example) add_executable (geometry_example geometry_example.cpp) -target_link_libraries (geometry_example CORSIKA8) +target_link_libraries (geometry_example CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (geometry_example) -# # logging back in March was not used -# #add_executable (logger_example logger_example.cpp) -# #target_link_libraries (logger_example CORSIKA8) -# #CORSIKA_REGISTER_EXAMPLE (logger_example) - add_executable (stack_example stack_example.cpp) -target_link_libraries (stack_example CORSIKA8) +target_link_libraries (stack_example CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (stack_example) add_executable (cascade_example cascade_example.cpp) -target_link_libraries (cascade_example CORSIKA8) +target_link_libraries (cascade_example CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (cascade_example) add_executable (boundary_example boundary_example.cpp) -target_link_libraries (boundary_example CORSIKA8) +target_link_libraries (boundary_example CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (boundary_example) add_executable (cascade_proton_example cascade_proton_example.cpp) -target_link_libraries (cascade_proton_example CORSIKA8) +target_link_libraries (cascade_proton_example CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (cascade_proton_example) add_executable (vertical_EAS vertical_EAS.cpp) -target_link_libraries (vertical_EAS CORSIKA8) +target_link_libraries (vertical_EAS CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (vertical_EAS RUN_OPTIONS 4 2 10000.) add_executable (stopping_power stopping_power.cpp) -target_link_libraries (stopping_power CORSIKA8) +target_link_libraries (stopping_power CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (stopping_power) add_executable (staticsequence_example staticsequence_example.cpp) -target_link_libraries (staticsequence_example CORSIKA8) +target_link_libraries (staticsequence_example CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (staticsequence_example) add_executable (particle_list_example particle_list_example.cpp) -target_link_libraries (particle_list_example CORSIKA8) +target_link_libraries (particle_list_example CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (particle_list_example) add_executable (em_shower em_shower.cpp) -target_link_libraries (em_shower CORSIKA8) +target_link_libraries (em_shower CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (em_shower RUN_OPTIONS "100.") add_executable (hybrid_MC hybrid_MC.cpp) -target_link_libraries (hybrid_MC CORSIKA8) +target_link_libraries (hybrid_MC CORSIKA8::CORSIKA8) CORSIKA_REGISTER_EXAMPLE (hybrid_MC RUN_OPTIONS 4 2 10000.) diff --git a/examples/cascade_proton_example.cpp b/examples/cascade_proton_example.cpp index 6381feff4d8159e10ec032743a91e2af6e3d109b..4b24f3b0148045a2db97546c37c6a2916e3c1d1e 100644 --- a/examples/cascade_proton_example.cpp +++ b/examples/cascade_proton_example.cpp @@ -90,7 +90,7 @@ int main() { stack.clear(); const Code beamCode = Code::Proton; const HEPMassType mass = Proton::mass; - const HEPEnergyType E0 = 100_GeV; + const HEPEnergyType E0 = 1000_GeV; double theta = 0.; double phi = 0.; diff --git a/externals/cnpy/CMakeLists.txt b/externals/cnpy/CMakeLists.txt index 0fa38d3bd16804b024f83700a2ba6c7c2c316c08..6e60f74d79ee4a641f398a37c9f108e5c487e0e9 100644 --- a/externals/cnpy/CMakeLists.txt +++ b/externals/cnpy/CMakeLists.txt @@ -21,12 +21,18 @@ target_include_directories ( cnpy INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> - $<INSTALL_INTERFACE:include/externals/cnpy> + $<INSTALL_INTERFACE:corsika_external/cnpy/include> + ) + +install ( + FILES cnpy.hpp + DESTINATION corsika_external/cnpy/include ) install ( TARGETS cnpy - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + EXPORT CORSIKA8PublicTargets + LIBRARY DESTINATION corsika_external/cnpy/lib + ARCHIVE DESTINATION corsika_external/cnpy/lib ) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt deleted file mode 100644 index ed2ead3f69b33185506f3cd720e30820f7c551f1..0000000000000000000000000000000000000000 --- a/modules/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required (VERSION 3.9) - -project ( - corsika_modules - VERSION 8.0.0 - DESCRIPTION "CORSIKA modules" - LANGUAGES CXX - ) - -include (FeatureSummary) - -# as long as there still are modules using it: -enable_language (Fortran) - -set (CMAKE_CXX_STANDARD 17) -set (CMAKE_CXX_EXTENSIONS OFF) - -# enable warnings and disallow non-standard language -# configure the various build types here, too -# FYI: optimizer flags: -O2 would not trade speed for size, neither O2/3 use fast-math -# debug: O0, relwithdebinfo: 02, release: O3, minsizerel: Os (all defaults) -set (CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wno-ignored-qualifiers") -set (CMAKE_Fortran_FLAGS "-std=legacy -Wfunction-elimination") - -# 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>") - -# order of subdirectories -add_subdirectory (Sibyll) -#add_subdirectory (Pythia) -add_subdirectory (QGSJetII) -add_subdirectory (UrQMD) diff --git a/modules/CMakeLists_PROPOSAL.txt b/modules/CMakeLists_PROPOSAL.txt index a752d8f7be5a72349f908c2721461a69f3665e58..c487b17cdb880e772e0ac7ccc723f1133fdf71f9 100644 --- a/modules/CMakeLists_PROPOSAL.txt +++ b/modules/CMakeLists_PROPOSAL.txt @@ -1,11 +1,12 @@ - -cmake_minimum_required(VERSION 3.8) - if(CMAKE_PROJECT_NAME STREQUAL corsika) message(STATUS "Including PROPOSAL as part of CORSIKA8") set (IN_CORSIKA8 ON) else(CMAKE_PROJECT_NAME STREQUAL corsika) set (IN_CORSIKA8 OFF) + + cmake_minimum_required(VERSION 3.8) + project(PROPOSAL VERSION 6.1.2 LANGUAGES CXX) + endif(CMAKE_PROJECT_NAME STREQUAL corsika) project(PROPOSAL VERSION 6.1.2 LANGUAGES CXX) @@ -70,6 +71,13 @@ install( LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) +else (NOT IN_CORSIKA8) +install( + TARGETS PROPOSAL + EXPORT CORSIKA8PublicTargets + LIBRARY DESTINATION lib/corsika + ARCHIVE DESTINATION lib/corsika +) endif (NOT IN_CORSIKA8) # input version from the project call, so the library knows its own version @@ -82,21 +90,37 @@ install( FILES ${PROJECT_BINARY_DIR}/include/PROPOSAL/version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/include/PROPOSAL ) -endif (NOT IN_CORSIKA8) target_include_directories( PROPOSAL PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> ) +else (NOT IN_CORSIKA8) +install( + FILES ${PROJECT_BINARY_DIR}/include/PROPOSAL/version.h + DESTINATION include/corsika_modules/PROPOSAL +) +target_include_directories( + PROPOSAL PUBLIC + $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include/corsika_modules> +) +endif (NOT IN_CORSIKA8) # install header files -if (NOT IN_CORSIKA8) file(GLOB_RECURSE INC_FILES ${PROJECT_SOURCE_DIR}/include/*) +if (NOT IN_CORSIKA8) foreach(INC_FILE ${INC_FILES}) file(RELATIVE_PATH REL_FILE ${PROJECT_SOURCE_DIR}/include ${INC_FILE}) get_filename_component(DIR ${REL_FILE} DIRECTORY) install(FILES include/${REL_FILE} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${DIR}) endforeach() +else (NOT IN_CORSIKA8) +foreach(INC_FILE ${INC_FILES}) + file(RELATIVE_PATH REL_FILE ${PROJECT_SOURCE_DIR}/include/ ${INC_FILE}) + get_filename_component(DIR ${REL_FILE} DIRECTORY) + install(FILES include/${REL_FILE} DESTINATION include/corsika_modules/${DIR}) +endforeach() endif (NOT IN_CORSIKA8) diff --git a/modules/conex b/modules/conex index 820f042b6a055276d465437c74160ef7c199b646..332e22472595377694e16163c76507f4c722556f 160000 --- a/modules/conex +++ b/modules/conex @@ -1 +1 @@ -Subproject commit 820f042b6a055276d465437c74160ef7c199b646 +Subproject commit 332e22472595377694e16163c76507f4c722556f diff --git a/modules/data b/modules/data index 8b76a9ca2599cd0ce1f204b17362eb06bbcf5277..3c8292657e68dc697925ce1ddec491b219075c51 160000 --- a/modules/data +++ b/modules/data @@ -1 +1 @@ -Subproject commit 8b76a9ca2599cd0ce1f204b17362eb06bbcf5277 +Subproject commit 3c8292657e68dc697925ce1ddec491b219075c51 diff --git a/modules/pythia/CMakeLists.txt b/modules/pythia/CMakeLists.txt deleted file mode 100644 index 3d2b269d493bda9b4b1cefb869b07a4bd198f165..0000000000000000000000000000000000000000 --- a/modules/pythia/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -include (ExternalProject) - -# eventually add AUTO here, too: -set (ThirdPartyChoiceValues "C8;SYSTEM" CACHE STRING - "List of possible values for the ThirdParty package choice") -mark_as_advanced (ThirdPartyChoiceValues) - -############################################################################## -# check for Pythia8: either use C8 or system-level installation - -message (STATUS "***** Configuring Pythia8 version") - -set (USE_PYTHIA8_C8 "C8" CACHE STRING - "Selection of pythia8 package. Can be \'C8\' or \'SYSTEM\'. Default: \'C8\'.") -set_property (CACHE USE_PYTHIA8_C8 PROPERTY STRINGS ${ThirdPartyChoiceValues}) -if (NOT (${USE_PYTHIA8_C8} IN_LIST ThirdPartyChoiceValues)) - message (SEND_ERROR "Illegal USE_PYTHIA8_C8=\"${USE_PYTHIA8_C8}\" can only be one of: ${ThirdPartyChoiceValues}") -endif (NOT (${USE_PYTHIA8_C8} IN_LIST ThirdPartyChoiceValues)) -message (STATUS "USE_PYTHIA8_C8='${USE_PYTHIA8_C8}'") - -add_library (C8::ext::pythia8 STATIC IMPORTED GLOBAL) -if ("x_${USE_PYTHIA8_C8}" STREQUAL "x_SYSTEM") - - find_package (Pythia8 8245 EXACT REQUIRED) - message (STATUS "Using system-level Pythia8 version ${Pythia8_VERSION} at ${Pythia8_PREFIX}") - set (Pythia8_INCLUDE_DIRS_CMAKE ${Pythia8_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - set_target_properties ( - C8::ext::pythia8 PROPERTIES - IMPORTED_LOCATION ${Pythia8_LIBRARY}/libpythia8.a - IMPORTED_LINK_INTERFACE_LIBRARIES dl - INTERFACE_INCLUDE_DIRECTORIES "${Pythia8_INCLUDE_DIRS_CMAKE}" - ) - set (Pythia8_FOUND 1 PARENT_SCOPE) - - set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build and install location, pythia8 is external - configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY) - configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY) - - message (STATUS "Pythia8 (system) at ${Pythia8_PREFIX}") - -else () - - set (_C8_Pythia8_VERSION "8245") - message (STATUS "Building modules/pythia8 using pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2") - message (STATUS "This will take a bit.....") - # this is not a full PYTHIA8 install, it is a bit simplified, e.g. no pythia8-config - ExternalProject_Add (pythia8 - URL ${CMAKE_CURRENT_SOURCE_DIR}/pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2 - URL_MD5 d3e951a2f101e8cfec26405cb61db83b - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pythia8/source" - INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/pythia8/install" - CONFIGURE_COMMAND ./configure --cxx-common=\\"${CMAKE_CXX_FLAGS} -O2 -fPIC\\" --prefix=${CMAKE_CURRENT_BINARY_DIR}/pythia8/install - INSTALL_COMMAND make install COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/bin ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/share/Pythia8/examples - BUILD_IN_SOURCE ON - EXCLUDE_FROM_ALL TRUE - ) - set (Pythia8_FOUND 1 PARENT_SCOPE) - ExternalProject_Get_Property (pythia8 INSTALL_DIR) # this is "make" - set (Pythia8_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/externals/pythia8) # this is "make install" - set (Pythia8_VERSION ${_C8_Pythia8_VERSION} CACHE STRING "Version of Pythia8") - set (Pythia8_PREFIX ${INSTALL_DIR}) - set (Pythia8_INCLUDE_DIR ${Pythia8_PREFIX}/include) - set (Pythia8_LIBRARY ${Pythia8_PREFIX}/lib/libpythia8.a) - add_dependencies (C8::ext::pythia8 pythia8) - - set (Pythia8_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/externals/pythia8) - set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build location - configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY) - set (CORSIKA_Pythia8_LOCATION ${Pythia8_INSTALL_DIR}) # install location - configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY) - - install (DIRECTORY ${INSTALL_DIR}/ DESTINATION ${Pythia8_INSTALL_DIR}) - - set (Pythia8_INCLUDE_DIRS_CMAKE ${Pythia8_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - - set_target_properties ( - C8::ext::pythia8 - PROPERTIES - IMPORTED_LOCATION ${Pythia8_LIBRARY} - IMPORTED_LINK_INTERFACE_LIBRARIES dl - INTERFACE_INCLUDE_DIRECTORIES "${Pythia8_INCLUDE_DIRS_CMAKE}" - ) - - message (STATUS "Pythia8 build at: ${INSTALL_DIR}, final install to: ${Pythia8_INSTALL_DIR}, include dirs: ${Pythia8_INCLUDE_DIRS_CMAKE}") -endif () - -# the install location of Pythia8 -install ( - FILES ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp - RENAME Pythia8ConfigurationDirectory.hpp - DESTINATION include/modules/pythia8 - ) - -##### add pythia8 to CORSIKA8 build -add_dependencies (CORSIKA8 C8::ext::pythia8) -target_link_libraries (CORSIKA8 INTERFACE C8::ext::pythia8) - diff --git a/modules/pythia8/CMakeLists.txt b/modules/pythia8/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..91433eb8ddcaec6a042eab83864a5763833ac046 --- /dev/null +++ b/modules/pythia8/CMakeLists.txt @@ -0,0 +1,123 @@ +include (ExternalProject) + +# eventually add AUTO here, too: +set (ThirdPartyChoiceValues "C8;SYSTEM" CACHE STRING + "List of possible values for the ThirdParty package choice") +mark_as_advanced (ThirdPartyChoiceValues) + +############################################################################## +# check for Pythia8: either use C8 or system-level installation + +message (STATUS "***** Configuring Pythia8 version") + +set (USE_Pythia8_C8 "C8" CACHE STRING + "Selection of pythia8 package. Can be \'C8\' or \'SYSTEM\'. Default: \'C8\'.") +set_property (CACHE USE_Pythia8_C8 PROPERTY STRINGS ${ThirdPartyChoiceValues}) +if (NOT (${USE_Pythia8_C8} IN_LIST ThirdPartyChoiceValues)) + message (SEND_ERROR "Illegal USE_Pythia8_C8=\"${USE_Pythia8_C8}\" can only be one of: ${ThirdPartyChoiceValues}") +endif (NOT (${USE_Pythia8_C8} IN_LIST ThirdPartyChoiceValues)) +message (STATUS "USE_Pythia8_C8='${USE_Pythia8_C8}'") + +set (CORSIKA_Pythia8_MODULE_DIR ${PROJECT_BINARY_DIR}/corsika/modules/pythia8) +file (MAKE_DIRECTORY ${CORSIKA_Pythia8_MODULE_DIR}) + +add_library (C8::ext::pythia8 STATIC IMPORTED GLOBAL) +if ("x_${USE_Pythia8_C8}" STREQUAL "x_SYSTEM") + + find_package (Pythia8 8245 EXACT REQUIRED) + message (STATUS "Using system-level Pythia8 version ${Pythia8_VERSION} at ${Pythia8_PREFIX}") + set (Pythia8_INCLUDE_DIRS ${Pythia8_INCLUDE_DIR}) + set_target_properties ( + C8::ext::pythia8 PROPERTIES + IMPORTED_LOCATION ${Pythia8_LIBRARY}/libpythia8.a + IMPORTED_LINK_INTERFACE_LIBRARIES dl + INTERFACE_INCLUDE_DIRECTORIES "${Pythia8_INCLUDE_DIRS}" + ) + set (Pythia8_FOUND 1 PARENT_SCOPE) + + set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build and install location, pythia8 is external + configure_file (Pythia8ConfigurationDirectory.hpp.in ${CORSIKA_Pythia8_MODULE_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY) + configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY) + + # install and build are both the same here since it is external + set (Pythia8_PREFIX_INSTALL ${Pythia8_PREFIX}) + set (Pythia8_LIBDIR ${Pythia8_LIBRARY}) + set (Pythia8_LIBDIR_INSTALL ${Pythia8_LIBRARY}) + set (Pythia8_INCDIR ${Pythia8_INCLUDE_DIR}) + set (Pythia8_INCDIR_INSTALL ${Pythia8_INCLUDE_DIR}) + + message (STATUS "Pythia8 (system) at ${Pythia8_PREFIX}") + +else () + + set (_C8_Pythia8_VERSION "8245") + message (STATUS "Building modules/pythia8 using pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2") + message (STATUS "This will take a bit.....") + # this is not a full Pythia8 install, it is a bit simplified, e.g. no pythia8-config, no examples + # and also, it is fitted into the normal CORSIKA8 install "include/corsika_modules/Pythia8, lib/corsika" + ExternalProject_Add (pythia8 + URL ${CMAKE_CURRENT_SOURCE_DIR}/pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2 + URL_MD5 d3e951a2f101e8cfec26405cb61db83b + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pythia8/source" + INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/pythia8/install" + CONFIGURE_COMMAND ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/pythia8/install + INSTALL_COMMAND make install + COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/bin + COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/share/Pythia8/examples + COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/include/corsika_modules + COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/lib/corsika + COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/include/corsika_modules/Pythia8 + COMMAND mv -f ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/include/Pythia8 ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/include/corsika_modules/ + COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/lib/libpythia8.a ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/lib/corsika/ + BUILD_IN_SOURCE ON + EXCLUDE_FROM_ALL TRUE + ) + set (Pythia8_FOUND 1 PARENT_SCOPE) + set (Pythia8_PREFIX_INSTALL ${CMAKE_INSTALL_PREFIX}) # this is "make install" + ExternalProject_Get_Property (pythia8 INSTALL_DIR) # this is "make" + set (Pythia8_VERSION ${_C8_Pythia8_VERSION} CACHE STRING "Version of Pythia8") + set (Pythia8_PREFIX ${INSTALL_DIR}) + set (Pythia8_INCLUDE_DIR ${Pythia8_PREFIX}/include/corsika_modules) + set (Pythia8_LIBDIR ${Pythia8_PREFIX}/lib/corsika) + set (Pythia8_LIBDIR_INSTALL ${Pythia8_PREFIX_INSTALL}/lib/corsika) + set (Pythia8_INCDIR ${Pythia8_PREFIX}/include/corsika_modules) + set (Pythia8_INCDIR_INSTALL ${Pythia8_PREFIX_INSTALL}/include/corsika_modules) + add_dependencies (C8::ext::pythia8 pythia8) + + set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build location + configure_file (Pythia8ConfigurationDirectory.hpp.in ${CORSIKA_Pythia8_MODULE_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY) + set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX_INSTALL}) # install location + configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY) + + install (DIRECTORY ${Pythia8_PREFIX}/ DESTINATION ${Pythia8_PREFIX_INSTALL}) + + set (Pythia8_INCLUDE_DIRS ${Pythia8_INCLUDE_DIR}) + + set_target_properties ( + C8::ext::pythia8 + PROPERTIES + IMPORTED_LOCATION ${Pythia8_LIBDIR}/libpythia8.a + IMPORTED_LINK_INTERFACE_LIBRARIES dl + INTERFACE_INCLUDE_DIRECTORIES "${Pythia8_INCLUDE_DIRS}" + ) + + message (STATUS "Pythia8 build at: ${Pythia8_PREFIX}, final install to: ${Pythia8_PREFIX_INSTALL}") +endif () + +# the install location of Pythia8 +install ( + FILES ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp + RENAME Pythia8ConfigurationDirectory.hpp + DESTINATION include/corsika/modules/pythia8 + ) + +##### add pythia8 to CORSIKA8 build +add_dependencies (CORSIKA8 C8::ext::pythia8) +target_link_libraries (CORSIKA8 INTERFACE C8::ext::pythia8) + +# we need those for exporting targets and dependencies: +set (Pythia8_FOUND 1 PARENT_SCOPE) +set (Pythia8_INCDIR ${Pythia8_INCDIR} PARENT_SCOPE) +set (Pythia8_INCDIR_INSTALL ${Pythia8_INCDIR_INSTALL} PARENT_SCOPE) +set (Pythia8_LIBDIR ${Pythia8_LIBDIR} PARENT_SCOPE) +set (Pythia8_LIBDIR_INSTALL ${Pythia8_LIBDIR_INSTALL} PARENT_SCOPE) diff --git a/modules/pythia/Pythia8ConfigurationDirectory.hpp.in b/modules/pythia8/Pythia8ConfigurationDirectory.hpp.in similarity index 100% rename from modules/pythia/Pythia8ConfigurationDirectory.hpp.in rename to modules/pythia8/Pythia8ConfigurationDirectory.hpp.in diff --git a/modules/pythia/pythia8245-stripped.tar.bz2 b/modules/pythia8/pythia8245-stripped.tar.bz2 similarity index 100% rename from modules/pythia/pythia8245-stripped.tar.bz2 rename to modules/pythia8/pythia8245-stripped.tar.bz2 diff --git a/modules/pythia/strip-pythia8-package.py b/modules/pythia8/strip-pythia8-package.py similarity index 100% rename from modules/pythia/strip-pythia8-package.py rename to modules/pythia8/strip-pythia8-package.py diff --git a/modules/qgsjetII/CMakeLists.txt b/modules/qgsjetII/CMakeLists.txt index 2ddb6b023f7e4d0320a7f827027c165d504b6a48..bef449e65c6e91cbc2066c73dcb389a1e2e1f87f 100644 --- a/modules/qgsjetII/CMakeLists.txt +++ b/modules/qgsjetII/CMakeLists.txt @@ -1,7 +1,3 @@ -cmake_minimum_required (VERSION 3.1) - -project (libQGSJetII) - set ( MODEL_SOURCES qgsjet-II-04-mod1.f @@ -15,27 +11,52 @@ set ( enable_language (Fortran) add_library (QGSJetII SHARED ${MODEL_SOURCES}) -set_target_properties (QGSJetII PROPERTIES POSITION_INDEPENDENT_CODE 1) +set_target_properties ( + QGSJetII + PROPERTIES + POSITION_INDEPENDENT_CODE 1 + ) target_include_directories ( QGSJetII PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> - $<INSTALL_INTERFACE:include/include> + $<INSTALL_INTERFACE:include/corsika_modules/qgsjetII> ) target_link_libraries (QGSJetII CorsikaData) add_library (QGSJetII_static STATIC ${MODEL_SOURCES}) -set_target_properties (QGSJetII_static PROPERTIES POSITION_INDEPENDENT_CODE 1) +set_target_properties ( + QGSJetII_static + PROPERTIES + POSITION_INDEPENDENT_CODE 1 + ) target_include_directories ( QGSJetII_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> - $<INSTALL_INTERFACE:include/include> + $<INSTALL_INTERFACE:include/corsika_modules/qgsjetII> ) target_link_libraries (QGSJetII_static CorsikaData) +install ( + FILES + ${MODEL_HEADERS} + DESTINATION include/corsika_modules/qgsjetII + ) + +install ( + TARGETS QGSJetII + EXPORT CORSIKA8PublicTargets + DESTINATION lib/corsika + ) + +install ( + TARGETS QGSJetII_static + EXPORT CORSIKA8PublicTargets + DESTINATION lib/corsika + ) # add qgsjetII to corsika8 build add_dependencies (CORSIKA8 QGSJetII_static) diff --git a/modules/sibyll/CMakeLists.txt b/modules/sibyll/CMakeLists.txt index 6dfe2d5c3f739d4494024adfe04bff1d3b861749..c974237befbc23ad84283a71759a94867aa5a7e6 100644 --- a/modules/sibyll/CMakeLists.txt +++ b/modules/sibyll/CMakeLists.txt @@ -15,23 +15,32 @@ set ( enable_language (Fortran) add_library (Sibyll SHARED ${MODEL_SOURCES}) -set_property(TARGET Sibyll PROPERTY POSITION_INDEPENDENT_CODE 1) - add_library (Sibyll_static STATIC ${MODEL_SOURCES}) -set_property(TARGET Sibyll_static PROPERTY POSITION_INDEPENDENT_CODE 1) + +set_target_properties ( + Sibyll + PROPERTIES + POSITION_INDEPENDENT_CODE 1 + ) + +set_target_properties ( + Sibyll_static + PROPERTIES + POSITION_INDEPENDENT_CODE 1 + ) target_include_directories ( Sibyll PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> - $<INSTALL_INTERFACE:include/include> + $<INSTALL_INTERFACE:include/corsika_modules/sibyll> ) target_include_directories ( Sibyll_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> - $<INSTALL_INTERFACE:include/include> + $<INSTALL_INTERFACE:include/corsika_modules/sibyll> ) target_link_libraries ( @@ -40,6 +49,24 @@ target_link_libraries ( gfortran ) +install ( + FILES + ${MODEL_HEADERS} + DESTINATION include/corsika_modules/sibyll + ) + +install ( + TARGETS Sibyll + EXPORT CORSIKA8PublicTargets + LIBRARY DESTINATION lib/corsika + ) + +install ( + TARGETS Sibyll_static + EXPORT CORSIKA8PublicTargets + ARCHIVE DESTINATION lib/corsika + ) + # add sibyll to corsika8 build add_dependencies (CORSIKA8 Sibyll_static) target_link_libraries (CORSIKA8 INTERFACE Sibyll_static) diff --git a/modules/urqmd/CMakeLists.txt b/modules/urqmd/CMakeLists.txt index 4c37ed1e0cd735cc3dca3364570e84dee550b5c0..b6048484806a24e2760f0684074def6726de1e7d 100644 --- a/modules/urqmd/CMakeLists.txt +++ b/modules/urqmd/CMakeLists.txt @@ -1,6 +1,3 @@ -cmake_minimum_required (VERSION 3.1) -project (libUrQMD) - set ( MODEL_SOURCES urqmd.cpp @@ -43,14 +40,48 @@ set ( ) enable_language (Fortran) + add_library (UrQMD SHARED ${MODEL_SOURCES}) -target_include_directories (UrQMD PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -set_target_properties (UrQMD PROPERTIES POSITION_INDEPENDENT_CODE 1) +target_include_directories (UrQMD PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + $<INSTALL_INTERFACE:include/corsika_modules/urqmd> + ) +set_target_properties ( + UrQMD + PROPERTIES + POSITION_INDEPENDENT_CODE 1 + ) add_library (UrQMD_static STATIC ${MODEL_SOURCES}) -target_include_directories (UrQMD_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -set_target_properties (UrQMD_static PROPERTIES POSITION_INDEPENDENT_CODE 1) +target_include_directories (UrQMD_static PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + $<INSTALL_INTERFACE:include/corsika_modules/urqmd> + ) +set_target_properties ( + UrQMD_static + PROPERTIES + POSITION_INDEPENDENT_CODE 1 + ) +install ( + FILES + ${MODEL_HEADERS} + DESTINATION include/corsika_modules/urqmd + ) + +install ( + TARGETS UrQMD + EXPORT CORSIKA8PublicTargets + LIBRARY DESTINATION lib/corsika + INCLUDES DESTINATION include/corsika_modules/urqmd + ) + +install ( + TARGETS UrQMD_static + EXPORT CORSIKA8PublicTargets + ARCHIVE DESTINATION lib/corsika + INCLUDES DESTINATION include/corsika_modules/urqmd + ) # add UrQMD to CORSIKA8 build add_dependencies (CORSIKA8 UrQMD_static) diff --git a/src/framework/core/CMakeLists.txt b/src/framework/core/CMakeLists.txt index 68423b1aa03bddcfd9ff4328e8e3b0b7be91987b..558b227f68801ec98c794c832ae5d8e654c1a703 100644 --- a/src/framework/core/CMakeLists.txt +++ b/src/framework/core/CMakeLists.txt @@ -24,3 +24,10 @@ add_custom_target (GenParticlesHeaders DEPENDS ${output_dir}/GeneratedParticleProperties.inc ${output_dir}/GeneratedParticleClasses.inc) add_dependencies (CORSIKA8 GenParticlesHeaders) + +install ( + FILES + ${output_dir}/GeneratedParticleProperties.inc + ${output_dir}/GeneratedParticleClasses.inc + DESTINATION include/corsika/framework/core + ) diff --git a/src/media/CMakeLists.txt b/src/media/CMakeLists.txt index 94b578560d71feacf38c2abec26f37446762e313..df3b6e9eb6ba14999912a2652aa3d1395a002f39 100644 --- a/src/media/CMakeLists.txt +++ b/src/media/CMakeLists.txt @@ -16,3 +16,8 @@ add_custom_command ( add_custom_target (GenMediaProperties DEPENDS ${output_dir}/GeneratedMediaProperties.inc) add_dependencies (CORSIKA8 GenMediaProperties) + +install ( + FILES ${output_dir}/GeneratedMediaProperties.inc + DESTINATION include/corsika/media + ) diff --git a/src/modules/qgsjetII/CMakeLists.txt b/src/modules/qgsjetII/CMakeLists.txt index 297e2690ddf4119494eb2736aa68293109699c69..36ebe9b693b927de9acfca03be3dc016440c4050 100644 --- a/src/modules/qgsjetII/CMakeLists.txt +++ b/src/modules/qgsjetII/CMakeLists.txt @@ -20,3 +20,7 @@ add_custom_command ( add_custom_target (SourceDirLinkQgs DEPENDS ${output_dir}/Generated.inc) add_dependencies (CORSIKA8 SourceDirLinkQgs) +install ( + FILES ${output_dir}/Generated.inc + DESTINATION include/corsika/modules/qgsjetII + ) diff --git a/src/modules/sibyll/CMakeLists.txt b/src/modules/sibyll/CMakeLists.txt index c2e6dd0bfc4840f59f4ce33a981186bdcff3b248..b3d97a12349a5a5f2cbd9917404a8685894f0096 100644 --- a/src/modules/sibyll/CMakeLists.txt +++ b/src/modules/sibyll/CMakeLists.txt @@ -20,3 +20,7 @@ add_custom_command ( add_custom_target (SourceDirLinkSib DEPENDS ${output_dir}/Generated.inc) add_dependencies (CORSIKA8 SourceDirLinkSib) +install ( + FILES ${output_dir}/Generated.inc + DESTINATION include/corsika/modules/sibyll + )