Skip to content

Commit

Permalink
Refactored detray::io into a single library.
Browse files Browse the repository at this point in the history
For the moment removed the DETRAY_IO_CSV and DETRAY_IO_JSON
cache variables completely. They were not used correctly in
every place anyway. So for now the project would always need
dfelibs and nlohmann_json to be available.

In the move made sure that every I/O header would actually be
tested for working by itelf. Which was mistakenly not the
case before.
  • Loading branch information
krasznaa committed Apr 4, 2023
1 parent 68e06a3 commit 3bb4dec
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 192 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ endif()
option( DETRAY_EIGEN_PLUGIN "Build Eigen math plugin" ON )
option( DETRAY_SMATRIX_PLUGIN "Build ROOT/SMatrix math plugin" OFF )
option( DETRAY_VC_PLUGIN "Build Vc based math plugin" ON )
option( DETRAY_IO_CSV "Build CSV IO module" ON )
option( DETRAY_IO_JSON "Build JSON IO module" ON)
option( DETRAY_SVG_DISPLAY "Build ActSVG display module" OFF)
option( DETRAY_BUILD_SYCL "Build the SYCL sources included in detray" OFF )
option( DETRAY_BUILD_CUDA "Build the CUDA sources included in detray"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ project would be built:
* Note that [Algebra Plugins](https://github.com/acts-project/algebra-plugins)
must have all of the appropriate options enabled for whichever option
is turned on from these.
- `DETRAY_IO_CSV`: Boolean option turning on the build of `detray::io_csv`, the
library allowing the reading of geometries from CSV files (`ON` by default);
- `DETRAY_DISPLAY`: Boolean option turning on the build of `detray::display`,
and additional helpers for displaying a geometry (`OFF` by default);
- `DETRAY_BUILD_CUDA`: Boolean option turning on the build of all CUDA code
Expand Down
6 changes: 2 additions & 4 deletions cmake/detray-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
set( DETRAY_EIGEN_PLUGIN @DETRAY_EIGEN_PLUGIN@ )
set( DETRAY_SMATRIX_PLUGIN @DETRAY_SMATRIX_PLUGIN@ )
set( DETRAY_VC_PLUGIN @DETRAY_VC_PLUGIN@ )
set( DETRAY_IO_CSV @DETRAY_IO_CSV@ )
set( DETRAY_DISPLAY @DETRAY_DISPLAY@ )
set( DETRAY_BUILD_CUDA @DETRAY_BUILD_CUDA@ )

Expand All @@ -27,9 +26,8 @@ include( CMakeFindDependencyMacro )
find_dependency( algebra-plugins )
find_dependency( Thrust )
find_dependency( vecmem )
if( DETRAY_IO_CSV )
find_dependency( dfelibs )
endif()
find_dependency( dfelibs )
find_dependency( nlohmann_json )
if( DETRAY_DISPLAY )
find_dependency( Matplot++ )
endif()
Expand Down
61 changes: 51 additions & 10 deletions io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,63 @@
# Detray library, part of the ACTS project (R&D line)
#
# (c) 2021 CERN for the benefit of the ACTS project
# (c) 2021-2023 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

# Let the user know what's happening.
message(STATUS "Building 'detray::io' component")

# Create the "main I/O library".
detray_add_library( detray_io io )
# Set up the core I/O library.
file( GLOB _detray_io_public_headers
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"include/detray/io/*.hpp" )
detray_add_library( detray_io io
${_detray_io_public_headers} )
target_link_libraries( detray_io INTERFACE
dfelibs::dfelibs nlohmann_json::nlohmann_json vecmem::core detray::core )

add_subdirectory ( payload )
# Set up libraries using particular algebra plugins.
detray_add_library( detray_io_array io_array )
target_link_libraries( detray_io_array
INTERFACE detray::io detray::algebra_array )

# Include all active components.
if( DETRAY_IO_CSV )
add_subdirectory( csv )
if( DETRAY_EIGEN_PLUGIN )
detray_add_library( detray_io_eigen io_eigen )
target_link_libraries( detray_io_eigen
INTERFACE detray::io detray::algebra_eigen )
endif()

if ( DETRAY_IO_JSON )
add_subdirectory( json )
endif()
if( DETRAY_SMATRIX_PLUGIN )
detray_add_library( detray_io_smatrix io_smatrix )
target_link_libraries( detray_io_smatrix
INTERFACE detray::io detray::algebra_smatrix )
endif()

if( DETRAY_VC_PLUGIN )
detray_add_library( detray_io_vc io_vc )
target_link_libraries( detray_io_vc
INTERFACE detray::io detray::algebra_vc )
endif()

# Test the public headers of the detray I/O libraries.
if( BUILD_TESTING AND DETRAY_BUILD_TESTING )
string( REPLACE "include/" "" _detray_io_public_headers
"${_detray_io_public_headers}" )
detray_test_public_headers( detray_io_array
${_detray_io_public_headers} )
if( DETRAY_EIGEN_PLUGIN )
detray_test_public_headers( detray_io_eigen
${_detray_io_public_headers} )
endif()
if( DETRAY_SMATRIX_PLUGIN )
detray_test_public_headers( detray_io_smatrix
${_detray_io_public_headers} )
endif()
if( DETRAY_VC_PLUGIN )
detray_test_public_headers( detray_io_vc
${_detray_io_public_headers} )
endif()
endif()

# Clean up.
unset( _detray_io_public_headers )
62 changes: 0 additions & 62 deletions io/csv/CMakeLists.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
/** Detray library, part of the ACTS project (R&D line)
*
* (c) 2022 CERN for the benefit of the ACTS project
* (c) 2022-2023 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

#include <array>
#include <optional>
#include <vector>

// Project include(s).
#include "detray/definitions/grid_axis.hpp"
#include "detray/io/io_payload.hpp"
#include "detray/io/json_algebra_io.hpp"
#include "detray/io/json_defs.hpp"

// System include(s).
#include <array>
#include <optional>
#include <vector>

namespace detray {

void to_json(nlohmann::json& j, const axis_payload& a) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 0 additions & 64 deletions io/json/CMakeLists.txt

This file was deleted.

19 changes: 0 additions & 19 deletions io/payload/CMakeLists.txt

This file was deleted.

11 changes: 5 additions & 6 deletions tests/unit_tests/cpu/array/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ detray_add_test( array
"array_volume.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::algebra_array )

# Set up the "conditional" tests.
if( DETRAY_IO_CSV )
detray_add_test( array_read_detector "array_read_detector.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::io
detray::algebra_array )
endif()
detray_add_test( array_read_detector "array_read_detector.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::io
detray::algebra_array )

# Set up the "conditional" test(s).
if( DETRAY_DISPLAY )
detray_add_test( array_display_masks "array_display_masks.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::display
Expand Down
11 changes: 5 additions & 6 deletions tests/unit_tests/cpu/eigen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ detray_add_test( eigen
"eigen_volume.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::algebra_eigen )

# Set up the "conditional" tests.
if( DETRAY_IO_CSV )
detray_add_test( eigen_read_detector "eigen_read_detector.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::io
detray::algebra_eigen )
endif()
detray_add_test( eigen_read_detector "eigen_read_detector.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::io
detray::algebra_eigen )

# Set up the "conditional" test(s).
if( DETRAY_DISPLAY )
detray_add_test( eigen_display_masks "eigen_display_masks.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::display
Expand Down
11 changes: 5 additions & 6 deletions tests/unit_tests/cpu/smatrix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ detray_add_test( smatrix
LINK_LIBRARIES GTest::gtest_main detray_tests_common
detray::algebra_smatrix )

# Set up the "conditional" tests.
if( DETRAY_IO_CSV )
detray_add_test( smatrix_read_detector "smatrix_read_detector.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::io
detray::algebra_smatrix )
endif()
detray_add_test( smatrix_read_detector "smatrix_read_detector.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::io
detray::algebra_smatrix )

# Set up the "conditional" test(s).
if( DETRAY_DISPLAY )
detray_add_test( smatrix_display_masks "smatrix_display_masks.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::display
Expand Down
11 changes: 5 additions & 6 deletions tests/unit_tests/cpu/vc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ detray_add_test( vc_array
"vc_array_volume.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::algebra_vc )

# Set up the "conditional" tests.
if( DETRAY_IO_CSV )
detray_add_test( vc_array_read_detector "vc_array_read_detector.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::io
detray::algebra_vc )
endif()
detray_add_test( vc_array_read_detector "vc_array_read_detector.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::io
detray::algebra_vc )

# Set up the "conditional" test(s).
if( DETRAY_DISPLAY )
detray_add_test( vc_array_display_masks "vc_array_display_masks.cpp"
LINK_LIBRARIES GTest::gtest_main detray_tests_common detray::display
Expand Down

0 comments on commit 3bb4dec

Please sign in to comment.