diff --git a/Framework/Utilities/CMakeLists.txt b/Framework/Utilities/CMakeLists.txt index b1c8ebed03c4d13a1c55589399e1b4d4afef29f8..5618ab4a8cf35be1e36630eac8d3f8d0ab627e95 100644 --- a/Framework/Utilities/CMakeLists.txt +++ b/Framework/Utilities/CMakeLists.txt @@ -31,9 +31,27 @@ set ( sgn.h CorsikaFenv.h MetaProgramming.h - SaveBoostHistogram.hpp ) +set ( + UTILITIES_DEPENDS + CORSIKAgeometry + CORSIKAunits + C8::ext::boost # so far only for MetaProgramming + C8::ext::eigen3 # for COMboost + ) + +if (TARGET cnpy) + LIST (APPEND + UTILITIES_HEADERS + SaveBoostHistogram.hpp + ) + LIST (APPEND + UTILITIES_DEPENDS + cnpy # for SaveBoostHistogram + ) +endif (TARGET cnpy) + set ( UTILITIES_NAMESPACE corsika/utl @@ -53,11 +71,7 @@ set_target_properties ( # target dependencies on other libraries (also the header onlys) target_link_libraries ( CORSIKAutilities - CORSIKAgeometry - CORSIKAunits - C8::ext::boost # so far only for MetaProgramming - C8::ext::eigen3 # for COMboost - cnpy # for SaveBoostHistogram + ${UTILITIES_DEPENDS} ) target_include_directories ( @@ -91,9 +105,11 @@ target_link_libraries ( CORSIKAtesting ) -CORSIKA_ADD_TEST(testSaveBoostHistogram) -target_link_libraries ( - testSaveBoostHistogram - CORSIKAutilities - CORSIKAtesting -) +if (TARGET cnpy) + CORSIKA_ADD_TEST(testSaveBoostHistogram) + target_link_libraries ( + testSaveBoostHistogram + CORSIKAutilities + CORSIKAtesting + ) +endif (TARGET cnpy) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 056f7074c9ed2d8d8246130790116b6e076b3148..b30fdf95b5289100a86006d4bd70c652eb93ef4a 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -35,7 +35,7 @@ message (STATUS "USE_BOOST_C8='${USE_BOOST_C8}'") add_library (C8::ext::boost INTERFACE IMPORTED GLOBAL) if ("x_${USE_BOOST_C8}" STREQUAL "x_SYSTEM") - find_package (Boost REQUIRED mp11 iterator core format interval optional type_index histogram) + find_package (Boost REQUIRED COMPONENTS mp11 iterator core format interval optional type_index histogram) message (STATUS "Using system-level boost version ${Boost_VERSION} at ${Boost_INCLUDE_DIR}") set_target_properties ( @@ -300,4 +300,13 @@ else (Boost_IOSTREAMS_FOUND) ) endif (Boost_IOSTREAMS_FOUND) -add_subdirectory(cnpy) + +# libz needed for cnpy, used for SaveHistograms +find_package (ZLIB QUIET) + +if (ZLIB_FOUND) + message (STATUS "Found ZLIB. Build cnpy for SaveHistograms") + add_subdirectory (cnpy) +else (ZLIB_FOUND) + message (WARNING "Did not find ZLIB. Cannot build cnpy for SaveHistograms") +endif (ZLIB_FOUND) diff --git a/ThirdParty/cnpy/CMakeLists.txt b/ThirdParty/cnpy/CMakeLists.txt index 868aafd1d751aac93cea5f8f597f090a83149de7..4a115728d660361d0159c1c309efdabb332b51c3 100644 --- a/ThirdParty/cnpy/CMakeLists.txt +++ b/ThirdParty/cnpy/CMakeLists.txt @@ -21,15 +21,13 @@ set_target_properties ( PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 1 -# PUBLIC_HEADER "${MODEL_HEADERS}" ) -find_package(ZLIB) - # target dependencies on other libraries (also the header onlys) target_link_libraries ( cnpy - ${ZLIB_LIBRARIES} + PUBLIC + ZLIB::ZLIB ) target_include_directories ( @@ -43,18 +41,5 @@ install ( TARGETS cnpy LIBRARY DESTINATION lib ARCHIVE DESTINATION lib -# PUBLIC_HEADER DESTINATION include/${MODEL_NAMESPACE} ) - -# -------------------- -# code unit testing -# CORSIKA_ADD_TEST(testNullModel) -#target_link_libraries ( -# testNullModel ProcessNullModel -# CORSIKAsetup -# CORSIKAgeometry -# CORSIKAunits -# CORSIKAthirdparty # for catch2 -# ) -