Skip to content

Commit

Permalink
Macro free dependency handling. (#892)
Browse files Browse the repository at this point in the history
In a prior commit the sources were restructured such that each optional
dependency is contained in separate files. This commit removes the
macros that controlled which dependencies are included.

To include the optional dependency Boost use:

    #include <highfive/highfive.hpp>
    #include <highfive/boost.hpp>

the order doesn't matter.
  • Loading branch information
1uc authored Feb 8, 2024
1 parent ab5b3f8 commit 0b47bad
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 32 deletions.
4 changes: 0 additions & 4 deletions include/highfive/bits/H5DataType_misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,3 @@ inline DataType create_datatype<bool>() {
}

} // namespace HighFive

#ifdef H5_USE_HALF_FLOAT
#include <highfive/half_float.hpp>
#endif
8 changes: 0 additions & 8 deletions include/highfive/bits/H5Inspector_misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,3 @@ struct inspector<T[N]> {

} // namespace details
} // namespace HighFive

#ifdef H5_USE_BOOST
#include <highfive/boost.hpp>
#endif

#ifdef H5_USE_EIGEN
#include <highfive/eigen.hpp>
#endif
3 changes: 0 additions & 3 deletions include/highfive/boost.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#ifdef H5_USE_BOOST

#include "bits/H5Inspector_decl.hpp"
#include "H5Exception.hpp"
Expand Down Expand Up @@ -160,5 +159,3 @@ struct inspector<boost::numeric::ublas::matrix<T>> {

} // namespace details
} // namespace HighFive

#endif
3 changes: 0 additions & 3 deletions include/highfive/eigen.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#ifdef H5_USE_EIGEN

#include "bits/H5Inspector_decl.hpp"
#include "H5Exception.hpp"
Expand Down Expand Up @@ -89,5 +88,3 @@ struct inspector<Eigen::Matrix<T, M, N>> {

} // namespace details
} // namespace HighFive

#endif
4 changes: 1 addition & 3 deletions include/highfive/half_float.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#ifdef H5_USE_HALF_FLOAT

#include <half.hpp>

Expand All @@ -16,6 +15,5 @@ inline AtomicType<float16_t>::AtomicType() {
// Floating point exponent bias
detail::h5t_set_ebias(_hid, 15);
}
} // namespace HighFive

#endif
} // namespace HighFive
4 changes: 1 addition & 3 deletions src/examples/boost_multi_array_2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
*/
#include <iostream>

#undef H5_USE_BOOST
#define H5_USE_BOOST

#include <boost/multi_array.hpp>
#include <highfive/highfive.hpp>
#include <highfive/boost.hpp>

using namespace HighFive;

Expand Down
5 changes: 1 addition & 4 deletions src/examples/boost_multiarray_complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
#include <algorithm>
#include <complex>

#undef H5_USE_BOOST
#define H5_USE_BOOST

#include <highfive/highfive.hpp>

#include <boost/multi_array.hpp>
#include <highfive/boost.hpp>

typedef std::complex<double> complex_t;

Expand Down
5 changes: 2 additions & 3 deletions src/examples/boost_ublas_double.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
*/
#include <iostream>

#undef H5_USE_BOOST
#define H5_USE_BOOST

#include <highfive/highfive.hpp>

#include <highfive/boost.hpp>

// In some versions of Boost (starting with 1.64), you have to include the serialization header
// before ublas
#include <boost/serialization/vector.hpp>
Expand Down
1 change: 1 addition & 0 deletions src/examples/create_dataset_half_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <vector>

#include <highfive/highfive.hpp>
#include <highfive/half_float.hpp>

const std::string FILE_NAME("create_dataset_half_float_example.h5");
const std::string DATASET_NAME("dset");
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ option(HIGHFIVE_TEST_SINGLE_INCLUDES "Enable testing single includes" FALSE)
if(HIGHFIVE_TEST_SINGLE_INCLUDES)
file(GLOB public_headers LIST_DIRECTORIES false RELATIVE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include/highfive/*.hpp)
foreach(PUBLIC_HEADER ${public_headers})
if(PUBLIC_HEADER STREQUAL "highfive/boost.hpp" AND NOT HIGHFIVE_USE_BOOST)
continue()
endif()

if(PUBLIC_HEADER STREQUAL "highfive/half_float.hpp" AND NOT HIGHFIVE_USE_HALF_FLOAT)
continue()
endif()

if(PUBLIC_HEADER STREQUAL "highfive/eigen.hpp" AND NOT HIGHFIVE_USE_EIGEN)
continue()
endif()

get_filename_component(CLASS_NAME ${PUBLIC_HEADER} NAME_WE)
configure_file(tests_import_public_headers.cpp "tests_${CLASS_NAME}.cpp" @ONLY)
add_executable("tests_include_${CLASS_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/tests_${CLASS_NAME}.cpp")
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/data_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <array>

#ifdef H5_USE_BOOST
#include <boost/multi_array.hpp>
#include <highfive/boost.hpp>
#endif

#include <highfive/bits/H5Inspector_misc.hpp>
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/tests_high_five.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ using base_test_types = std::tuple<int,
fcomplex>;

#ifdef H5_USE_HALF_FLOAT
#include <highfive/half_float.hpp>

using float16_t = half_float::half;
using numerical_test_types =
decltype(std::tuple_cat(std::declval<base_test_types>(), std::tuple<float16_t>()));
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/tests_high_five_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
#include <highfive/highfive.hpp>
#include "tests_high_five.hpp"

#ifdef H5_USE_BOOST
#include <highfive/boost.hpp>
#endif

#ifdef H5_USE_EIGEN
#include <highfive/eigen.hpp>
#endif


using namespace HighFive;
using Catch::Matchers::Equals;

Expand Down
1 change: 1 addition & 0 deletions tests/unit/tests_high_five_multi_dims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#ifdef H5_USE_BOOST
#include <boost/multi_array.hpp>
#include <highfive/boost.hpp>
#endif

#include <catch2/catch_test_macros.hpp>
Expand Down

0 comments on commit 0b47bad

Please sign in to comment.