Skip to content

Commit 9877cb2

Browse files
HenrZureneSchm
andauthored
1501 Add CMake option to allow building without HDF5 (#1502)
- Add `MEMILIO_ENABLE_HDF5` option to allow building without hdf5. - Update Doc and CI run configuration. Co-authored-by: reneSchm <[email protected]>
1 parent 9e825cf commit 9877cb2

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

.github/actions/linux-build/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ runs:
4040
sudo apt-get -qq update
4141
sudo apt-get -qq -y install lcov ccache
4242
if [[ "${{ inputs.optional-dependencies }}" == "ON" ]]; then
43-
sudo apt-get -qq -y install libhdf5-dev
43+
sudo apt-get -qq -y install libhdf5-dev
4444
fi
4545
if [[ "${{ inputs.compiler }}" == "gcc" ]]; then
4646
if [[ "${{ inputs.version }}" == "min" ]]; then
@@ -97,7 +97,7 @@ runs:
9797
exit 1
9898
fi
9999
mkdir -p build && cd build
100-
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ inputs.config }} -DMEMILIO_ENABLE_IPOPT=ON -DMEMILIO_TEST_COVERAGE=${{ inputs.coverage }} -DMEMILIO_SANITIZE_ADDRESS=${{ inputs.sanitizers }} -DMEMILIO_SANITIZE_UNDEFINED=${{ inputs.sanitizers }} -DMEMILIO_USE_BUNDLED_JSONCPP=${{ inputs.optional-dependencies }} -DMEMILIO_ENABLE_OPENMP=${{ inputs.openmp }} ..
100+
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ inputs.config }} -DMEMILIO_ENABLE_IPOPT=ON -DMEMILIO_TEST_COVERAGE=${{ inputs.coverage }} -DMEMILIO_SANITIZE_ADDRESS=${{ inputs.sanitizers }} -DMEMILIO_SANITIZE_UNDEFINED=${{ inputs.sanitizers }} -DMEMILIO_USE_BUNDLED_JSONCPP=${{ inputs.optional-dependencies }} -DMEMILIO_ENABLE_OPENMP=${{ inputs.openmp }} -DMEMILIO_ENABLE_HDF5=${{ inputs.optional-dependencies }} ..
101101
make -j4
102102
- name: create build dir archive
103103
shell: bash

.github/actions/linux-test/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ runs:
2727
shell: bash
2828
run: |
2929
sudo apt-get -qq update
30-
sudo apt-get -qq -y install libhdf5-10* wget gnupg lcov
30+
sudo apt-get -qq -y install wget gnupg lcov
31+
if [[ "${{ inputs.optional-deps }}" == "ON" ]]; then
32+
sudo apt-get -qq -y install libhdf5-10*
33+
fi
3134
sudo apt-get -qq update
3235
- name: Download built test directory
3336
uses: actions/download-artifact@v4

cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ option(MEMILIO_BUILD_SHARED_LIBS "Build memilio as a shared library." ON)
2020
option(MEMILIO_BUILD_STATIC_LIBS "Build memilio as a static library." ON)
2121
option(MEMILIO_ENABLE_MPI "Build memilio with MPI." OFF)
2222
option(MEMILIO_ENABLE_OPENMP "Enable Multithreading with OpenMP." OFF)
23+
option(MEMILIO_ENABLE_HDF5 "Build memilio with HDF5 IO support." ON)
2324
option(MEMILIO_ENABLE_WARNINGS "Build memilio with warnings." ON)
2425
option(MEMILIO_ENABLE_WARNINGS_AS_ERRORS "Build memilio with warnings as errors." ON)
2526
option(MEMILIO_ENABLE_IPOPT "Enable numerical optimization with Ipopt, requires a Fortran compiler." OFF)

cpp/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Options can be specified with `cmake .. -D<OPTION>=<VALUE>` or by editing the `b
5959
- `MEMILIO_SANITIZE_ADDRESS/_UNDEFINED`: compile with specified sanitizers to check correctness, ON or OFF, default OFF.
6060
- `MEMILIO_ENABLE_OPENMP`: compile MEmilio with multithreading using OpenMP, ON or OFF, default OFF.
6161
- `MEMILIO_ENABLE_MPI`: compile MEmilio with distributed memory parallelization using MPI. ON or OFF, default OFF. Requires an MPI implementation to be installed on the system.
62+
- `MEMILIO_ENABLE_HDF5`: build MEmilio with HDF5 IO support, ON or OFF, default ON. If OFF, HDF5 is not searched for and features like `save_result`/`read_result` are disabled.
6263
- `MEMILIO_ENABLE_WARNINGS`: enable compilation warnings (beyond those enabled in the compiler by default). ON or OFF, default ON.
6364
- `MEMILIO_ENABLE_WARNINGS_AS_ERRORS`: compilation warnings are treated as compilation errors. ON or OFF, default ON.
6465
- `MEMILIO_ENABLE_PROFILING`: compile with runtime profiling support. ON or OFF, default OFF. See [here](benchmarks/profiling.md) for information.

cpp/thirdparty/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,14 @@ else()
145145
endif()
146146

147147
# ## HDF5
148-
find_package(HDF5 COMPONENTS C)
148+
if(MEMILIO_ENABLE_HDF5)
149+
find_package(HDF5 COMPONENTS C)
149150

150-
if(HDF5_FOUND)
151-
set(MEMILIO_HAS_HDF5 ON)
152-
else()
153-
message(WARNING "HDF5 was not found. Memilio will be built without some IO features. Install HDF5 Libraries and set the HDF5_DIR cmake variable to the directory containing the hdf5-config.cmake file to build with HDF5.")
151+
if(HDF5_FOUND)
152+
set(MEMILIO_HAS_HDF5 ON)
153+
else()
154+
message(WARNING "HDF5 was not found. Memilio will be built without some IO features. Install HDF5 Libraries and set the HDF5_DIR cmake variable to the directory containing the hdf5-config.cmake file to build with HDF5.")
155+
endif()
154156
endif()
155157

156158
# ## JSONCPP

docs/source/cpp/installation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ Additional options can be specified by appending one or more ``-D<OPTION>=<VALUE
156156
- Compile MEmilio with multithreading using OpenMP, ON or OFF, default OFF.
157157
* - ``MEMILIO_ENABLE_MPI``
158158
- Compile MEmilio with distributed memory parallelization using MPI. ON or OFF, default OFF. Requires an MPI implementation to be installed on the system.
159+
* - ``MEMILIO_ENABLE_HDF5``
160+
- Build MEmilio with HDF5 IO support, ON or OFF, default ON. If OFF, HDF5 is not searched for and features like ``save_result``/``read_result`` are disabled.
159161
* - ``MEMILIO_ENABLE_WARNINGS``
160162
- Enable compilation warnings (beyond those enabled in the compiler by default). ON or OFF, default ON.
161163
* - ``MEMILIO_ENABLE_WARNINGS_AS_ERRORS``

0 commit comments

Comments
 (0)