diff --git a/Documentation/Examples/CMakeLists.txt b/Documentation/Examples/CMakeLists.txt index 1c4a2e76c84b9d32a567fd07792987841416b784..5ac721c54ac3d755bd013d241c9960c33252c1da 100644 --- a/Documentation/Examples/CMakeLists.txt +++ b/Documentation/Examples/CMakeLists.txt @@ -8,32 +8,60 @@ target_link_libraries (particle_list_example CORSIKAparticles CORSIKAunits CORSI CORSIKA_ADD_EXAMPLE (geometry_example) target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits) +CORSIKA_ADD_EXAMPLE (logger_example) +target_link_libraries (logger_example CORSIKAunits CORSIKAlogging) + CORSIKA_ADD_EXAMPLE (stack_example) -target_link_libraries (stack_example SuperStupidStack CORSIKAunits) +target_link_libraries (stack_example SuperStupidStack CORSIKAunits + CORSIKAlogging) # address sanitizer is making this example too slow, so we only do "undefined" CORSIKA_ADD_EXAMPLE (boundary_example) target_link_libraries (boundary_example - SuperStupidStack - CORSIKAunits - CORSIKAlogging - CORSIKArandom - ProcessSibyll - ProcessPythia8 - ProcessProposal - CORSIKAcascade - ProcessTrackWriter - ProcessParticleCut - ProcessTrackingLine - CORSIKAprocesses - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - CORSIKAprocesssequence - ) + SuperStupidStack + CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + CORSIKAcascade + ProcessTrackWriter + ProcessParticleCut + ProcessTrackingLine + ProcessPythia8 + ProcessProposal + CORSIKAprocesses + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAprocesssequence + ) CORSIKA_ADD_EXAMPLE (cascade_example) target_link_libraries (cascade_example + SuperStupidStack + CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + CORSIKAcascade + ProcessEnergyLoss + ProcessTrackWriter + ProcessStackInspector + ProcessTrackingLine + ProcessParticleCut + ProcessHadronicElasticModel + ProcessStackInspector + CORSIKAprocesses + CORSIKAcascade + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAprocesssequence + ) + +if (Pythia8_FOUND) + CORSIKA_ADD_EXAMPLE (cascade_proton_example) + target_link_libraries (cascade_proton_example SuperStupidStack CORSIKAunits CORSIKAlogging @@ -48,7 +76,6 @@ target_link_libraries (cascade_example ProcessTrackWriter ProcessStackInspector ProcessTrackingLine - ProcessProposal ProcessParticleCut ProcessOnShellCheck ProcessHadronicElasticModel @@ -61,78 +88,8 @@ target_link_libraries (cascade_example CORSIKAprocesssequence ) -if (Pythia8_FOUND) - CORSIKA_ADD_EXAMPLE (cascade_proton_example) - target_link_libraries (cascade_proton_example - SuperStupidStack - CORSIKAunits - CORSIKAlogging - CORSIKArandom - ProcessSibyll - ProcessPythia - CORSIKAcascade - ProcessEnergyLoss - ProcessTrackWriter - ProcessStackInspector - ProcessTrackingLine - ProcessParticleCut - ProcessHadronicElasticModel - ProcessStackInspector - CORSIKAprocesses - CORSIKAcascade - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - CORSIKAprocesssequence - ) - - CORSIKA_ADD_EXAMPLE (vertical_EAS RUN_OPTIONS 4 2 10000.) - target_link_libraries (vertical_EAS - SuperStupidStack - CORSIKAunits - CORSIKAlogging - CORSIKArandom - ProcessSibyll - ProcessPythia - ProcessUrQMD - ProcessSwitch - CORSIKAcascade - ProcessEnergyLoss - ProcessObservationPlane - ProcessInteractionCounter - ProcessTrackWriter - ProcessTrackingLine - ProcessParticleCut - ProcessStackInspector - ProcessLongitudinalProfile - CORSIKAprocesses - CORSIKAcascade - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - CORSIKAprocesssequence - ) -endif() - -CORSIKA_ADD_EXAMPLE (stopping_power stopping_power) -target_link_libraries (stopping_power - SuperStupidStack - CORSIKAunits - ProcessEnergyLoss - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - ) - -CORSIKA_ADD_EXAMPLE (staticsequence_example) -target_link_libraries (staticsequence_example - CORSIKAprocesssequence - CORSIKAunits - CORSIKAgeometry - CORSIKAlogging) - -CORSIKA_ADD_EXAMPLE (proposal_example RUN_OPTIONS 100.) -target_link_libraries (proposal_example + CORSIKA_ADD_EXAMPLE (vertical_EAS RUN_OPTIONS 4 2 10000.) + target_link_libraries (vertical_EAS SuperStupidStack CORSIKAunits CORSIKAlogging @@ -141,7 +98,6 @@ target_link_libraries (proposal_example ProcessObservationPlane ProcessInteractionCounter ProcessTrackWriter - ProcessProposal ProcessTrackingLine ProcessParticleCut ProcessStackInspector @@ -153,3 +109,21 @@ target_link_libraries (proposal_example CORSIKAenvironment CORSIKAprocesssequence ) +endif() + +CORSIKA_ADD_EXAMPLE (stopping_power stopping_power) +target_link_libraries (stopping_power + SuperStupidStack + CORSIKAunits + ProcessEnergyLoss + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + ) + +CORSIKA_ADD_EXAMPLE (staticsequence_example) +target_link_libraries (staticsequence_example + CORSIKAprocesssequence + CORSIKAunits + CORSIKAgeometry + CORSIKAlogging) diff --git a/Processes/Proposal/CMakeLists_PROPOSAL.txt b/Processes/Proposal/CMakeLists_PROPOSAL.txt new file mode 100644 index 0000000000000000000000000000000000000000..e947d10e96670342f6f64375219ff5a615c84045 --- /dev/null +++ b/Processes/Proposal/CMakeLists_PROPOSAL.txt @@ -0,0 +1,179 @@ + +cmake_minimum_required(VERSION 3.8) + +project(PROPOSAL VERSION 6.1.2 LANGUAGES CXX) + +IF(APPLE) + # In newer version of cmake this will be the default + SET(CMAKE_MACOSX_RPATH 1) +ENDIF(APPLE) + +# sets standard installtion paths +include(GNUInstallDirs) + +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) +### full RPATH +### copied from https://cmake.org/Wiki/CMake_RPATH_handling +### set the RPATH so that for using PROPOSAL in python +### the DYLD_LIBRARY_PATH must not be set in the bashrc +### But for using PROPOSAL as c-Library, this path still +### has to be set + +# use, i.e. don't skip the full RPATH for the build tree +SET(CMAKE_SKIP_BUILD_RPATH FALSE) + +# when building, don't use the install RPATH already +# (but later on when installing) +OPTION(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib64") +message(STATUS "${CMAKE_INSTALL_RPATH}") + +# add the automatically determined parts of the RPATH +# which point to directories outside the build tree to the install RPATH +OPTION(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +### end full RPATH + +# Some additional options +OPTION(ADD_PYTHON "Choose to compile the python wrapper library" ON) +endif(CMAKE_PROJECT_NAME STREQUAL corsika) + +################################################################# +#################### PROPOSAL ######################## +################################################################# +file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/src/PROPOSAL/*) +if (IN_CORSIKA8) +add_library(PROPOSAL STATIC ${SRC_FILES}) +else (IN_CORSIKA8) +add_library(PROPOSAL SHARED ${SRC_FILES}) +endif (IN_CORSIKA8) + +add_library(PROPOSAL::PROPOSAL ALIAS PROPOSAL) +target_compile_features(PROPOSAL PUBLIC cxx_std_11) +set_target_properties(PROPOSAL PROPERTIES CXX_EXTENSIONS OFF) +target_include_directories( + PROPOSAL PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:include> +) +target_compile_options(PROPOSAL PRIVATE -Wall -Wextra -Wnarrowing -Wpedantic -fdiagnostics-show-option -Wno-format-security) +install( + TARGETS PROPOSAL + EXPORT PROPOSALTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +# input version from the project call, so the library knows its own version +configure_file( + "${PROJECT_SOURCE_DIR}/include/PROPOSAL/version.h.in" + "${PROJECT_BINARY_DIR}/include/PROPOSAL/version.h" +) +install( + FILES ${PROJECT_BINARY_DIR}/include/PROPOSAL/version.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/include/PROPOSAL +) +target_include_directories( + PROPOSAL PUBLIC + $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include> +) + +# install header files +file(GLOB_RECURSE INC_FILES ${PROJECT_SOURCE_DIR}/include/*) +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() + + +if(NOT IS_SYMLINK ${CMAKE_BINARY_DIR}/resources) + execute_process(COMMAND ln -sv ${CMAKE_SOURCE_DIR}/resources ${CMAKE_BINARY_DIR}/resources OUTPUT_VARIABLE link_msg OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Symlink to resources created:") + message(STATUS " ${link_msg}") +endif() + + +################################################################# +################# spdlog ####################### +################################################################# + +if (NOT IN_CORSIKA8) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +add_subdirectory("vendor/spdlog") +endif (NOT IN_CORSIKA8) +target_link_libraries(PROPOSAL PRIVATE spdlog::spdlog) + + +################################################################# +################# Tests ######################## +################################################################# + +if (NOT IN_CORSIKA8) +if(CMAKE_PROJECT_NAME STREQUAL PROPOSAL) + include(CTest) +endif() +if(CMAKE_PROJECT_NAME STREQUAL PROPOSAL AND BUILD_TESTING) + add_subdirectory(tests) +else() + MESSAGE(STATUS "No tests will be build.") +endif() +endif (NOT IN_CORSIKA8) + +################################################################# +################# Documentation ######################## +################################################################# +if (NOT IN_CORSIKA8) +add_subdirectory(doc) +endif (NOT IN_CORSIKA8) + + +################################################################# +################# python ######################### +################################################################# +if (NOT IN_CORSIKA8) +IF(ADD_PYTHON) + message(STATUS "Building the python wrapper library.") + find_package(PythonLibs REQUIRED) + add_subdirectory("vendor/pybind11") + file(GLOB_RECURSE PYTHON_SRC_FILES ${PROJECT_SOURCE_DIR}/interface/python/*) + + pybind11_add_module(pyproposal SHARED ${PYTHON_SRC_FILES}) + set_target_properties(pyproposal PROPERTIES OUTPUT_NAME proposal) + target_include_directories(pyproposal PRIVATE ${PYTHON_INCLUDE_DIRS}) + target_include_directories(pyproposal PRIVATE ${PROJECT_SOURCE_DIR}/interface/python) + target_link_libraries(pyproposal PRIVATE PROPOSAL) + target_compile_options(pyproposal PRIVATE -fvisibility=hidden) + install(TARGETS pyproposal EXPORT PROPOSALTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) +ELSE(ADD_PYTHON) + MESSAGE(STATUS "No python wrapper library will be build.") +ENDIF(ADD_PYTHON) +endif (NOT IN_CORSIKA8) + + + +################################################################# +################# INSTALLATION ################### +################################################################# +if (NOT IN_CORSIKA8) +install( + EXPORT PROPOSALTargets + FILE PROPOSALConfig.cmake + NAMESPACE PROPOSAL:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PROPOSAL +) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "PROPOSALConfigVersion.cmake" + VERSION ${PACKAGE_VERSION} + COMPATIBILITY SameMajorVersion +) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/PROPOSALConfigVersion.cmake" + DESTINATION lib/cmake/PROPOSAL +) +endif (NOT IN_CORSIKA8) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 8b9b50be42e023054bcf82782713cfa34410cae7..98eaf3a72346dc2a153bfbc668d9f0479bfcbcc6 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -18,9 +18,9 @@ mark_as_advanced (ThirdPartyChoiceValues) ############################################################################## # Build spdlog -set (CMAKE_POSITION_INDEPENDENT_CODE ON) # this is needed for PROPOSAL... since it is dynamic +#set (CMAKE_POSITION_INDEPENDENT_CODE ON) # this is needed for PROPOSAL... since it is dynamic add_subdirectory (spdlog) -unset (CMAKE_POSITION_INDEPENDENT_CODE) +#unset (CMAKE_POSITION_INDEPENDENT_CODE) ############################################################################## # check for boost: either use C8 or system-level installation