Skip to content

Commit 036bcf9

Browse files
authored
Include json via CMake (#87)
1 parent ab37fd6 commit 036bcf9

File tree

11 files changed

+26
-20657
lines changed

11 files changed

+26
-20657
lines changed

.github/workflows/build_and_test_mac.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
brew install gnu-time gcc@15
3232
brew install open-mpi --build-from-source --cc=gcc-15
3333
brew install hdf5-mpi --build-from-source --cc=gcc-15
34-
brew install fftw eigen
34+
brew install fftw eigen nlohmann-json
3535
3636
- name: Set up pixi
3737
uses: prefix-dev/[email protected]

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ repos:
2020
hooks:
2121
- id: clang-format
2222
args: ['--style=file']
23-
exclude: "include/json.hpp"
2423
types_or: [c++]

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## latest
44

5+
- Include nlohmann-json via cmake [#87](https://github.com/DataAnalyticsEngineering/FANS/pull/87)
56
- Relaxed versions in Pixi build workflow [#86](https://github.com/DataAnalyticsEngineering/FANS/pull/86)
67
- Bump version in MacOS CI [#85](https://github.com/DataAnalyticsEngineering/FANS/pull/85)
78
- Pixi build workflow for MacOS and Linux [#82](https://github.com/DataAnalyticsEngineering/FANS/pull/82) [#84](https://github.com/DataAnalyticsEngineering/FANS/pull/84)

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ if (FANS_LIBRARY_FOR_MICRO_MANAGER)
9898
)
9999
FetchContent_MakeAvailable(pybind11)
100100
endif()
101-
101+
find_package(nlohmann_json REQUIRED)
102102
# ##############################################################################
103103
# TARGETS
104104
# ##############################################################################
@@ -141,7 +141,6 @@ target_include_directories(FANS_FANS PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SO
141141
# FANS.h header that consuming projects can use
142142
set_property(TARGET FANS_FANS PROPERTY PUBLIC_HEADER
143143
include/general.h
144-
include/json.hpp
145144
include/matmodel.h
146145
include/reader.h
147146
include/solverCG.h
@@ -200,6 +199,7 @@ target_link_libraries(FANS_FANS PUBLIC ${FFTW3_LIBRARIES})
200199
target_compile_definitions(FANS_FANS PUBLIC ${FFTW3_DEFINITIONS})
201200

202201
target_link_libraries(FANS_FANS PUBLIC Eigen3::Eigen)
202+
target_link_libraries(FANS_FANS PUBLIC nlohmann_json::nlohmann_json)
203203

204204
target_link_libraries(FANS_main PRIVATE FANS::FANS)
205205

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ FANS has the following dependencies:
2424
- HDF5 with MPI support
2525
- Eigen3
2626
- FFTW3 with MPI support
27+
- nlohmann-json (for JSON input parsing)
2728

2829
### Installing dependencies
2930

@@ -35,7 +36,8 @@ FANS has the following dependencies:
3536
libopenmpi-dev \
3637
libeigen3-dev \
3738
libfftw3-dev \
38-
libfftw3-mpi-dev
39+
libfftw3-mpi-dev \
40+
nlohmann-json3-dev
3941
```
4042

4143
- On macOS, you can obtain the dependencies using `brew` and set the environment variables:
@@ -44,7 +46,7 @@ FANS has the following dependencies:
4446
brew install gnu-time cmake gcc@15
4547
brew install open-mpi --build-from-source --cc=gcc-15
4648
brew install hdf5-mpi --build-from-source --cc=gcc-15
47-
brew install fftw eigen
49+
brew install fftw eigen nlohmann-json
4850

4951
export CC=gcc-15 CXX=g++-15 MPICC=mpicc MPICXX=mpicxx
5052
```
@@ -77,14 +79,15 @@ Spack is a package manager designed for high-performance computing environments.
7779
spack install hdf5 +cxx +mpi
7880
spack install eigen
7981
spack install fftw +mpi
82+
spack install nlohmann-json
8083
```
8184

8285
Additionally, optimized FFTW implementations can be used depending on your system's architecture, for example `amdfftw` (For AMD systems) or `cray-fftw` (For Cray systems), or `fujitsu-fftw` (For Fujitsu systems).
8386
8487
3. **Load Dependencies** Once dependencies are installed, load them before building:
8588
8689
```bash
87-
spack load cmake mpi hdf5 eigen fftw
90+
spack load cmake mpi hdf5 eigen fftw nlohmann-json
8891
```
8992
9093
## Building

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ RUN apt-get update -qq && apt-get install -y --no-install-recommends \
4040
libeigen3-dev \
4141
libfftw3-dev \
4242
libfftw3-mpi-dev \
43+
nlohmann-json3-dev \
4344
# Required for preCICE Micro Manager Python bindings
4445
python3-dev \
4546
# Clean up

include/general.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
using namespace std;
1818

1919
// JSON
20-
#include <json.hpp>
20+
#include <nlohmann/json.hpp>
2121
using nlohmann::json;
2222
using namespace nlohmann;
2323

0 commit comments

Comments
 (0)