Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
a6cbe07
The changes required to compile one program with modular maths
sebsjames Mar 4, 2026
f9a38ad
Removes some unnecessary headers
sebsjames Mar 4, 2026
447a015
gcc 14 or probably higher
sebsjames Mar 4, 2026
005cce3
Attempting to compile any VIsual other than CoordArrows causes circul…
sebsjames Mar 4, 2026
7966abd
Minor change in maths
sebsjames Mar 5, 2026
3ce2211
Updates before batch upgrades
sebsjames Mar 5, 2026
fa82e13
Converts to imports
sebsjames Mar 5, 2026
c75f9fc
Changes required to compile showcase with moduled maths
sebsjames Mar 5, 2026
7686f17
Welcome to circular dependency hell.
sebsjames Mar 5, 2026
c892bd7
The circular dependency problem is that VisualBase needs to know abou…
sebsjames Mar 5, 2026
d4b27ca
Trying to write VisualModels out of mplot::Visual
sebsjames Mar 5, 2026
e91c76a
The VisualModel-based coords is now called CoordsVisual
sebsjames Mar 5, 2026
8c3ed3f
Still got the circ dep.
sebsjames Mar 5, 2026
fa2728d
The start if an idea to allow VisualModels to get state from VisualRe…
sebsjames Mar 5, 2026
afe49bf
More hacking, needto be more awake really
sebsjames Mar 5, 2026
8bdb664
Removing base classes where unnecessary
sebsjames Mar 6, 2026
af3c1ef
WIP
sebsjames Mar 6, 2026
40c7d8f
Compiles to objects now - just got to figure out linking
sebsjames Mar 6, 2026
c4f305a
Compile glad as a lib and link
sebsjames Mar 6, 2026
44c4bfd
And that gets the fonts into a library
sebsjames Mar 6, 2026
15313c5
Helloworld now runssgit add -u
sebsjames Mar 6, 2026
9312e7a
Trying to make helloworld and rod work in clang-20 and gcc-15. Not th…
sebsjames Mar 6, 2026
679c6e6
Clang23 now builds both helloworld AND rod!
sebsjames Mar 6, 2026
cbad5a1
Prefer static linking of glad
sebsjames Mar 6, 2026
f8e2e40
Forgotten files
sebsjames Mar 6, 2026
73c7518
grid_simple now works. VisualModel, VisualDataModel modularized.
sebsjames Mar 8, 2026
891e12e
graph1 now compiles
sebsjames Mar 8, 2026
e1ba0f3
modularize GraphVisual
sebsjames Mar 8, 2026
0d0461b
Preemptive update of readme
sebsjames Mar 8, 2026
4338b73
Breadcrumbs example works
sebsjames Mar 8, 2026
ea9609f
modularize GridVisual
sebsjames Mar 8, 2026
2b582bb
Modularlized RodVisual
sebsjames Mar 8, 2026
47115bc
Back to just one CoordArrows, and that one derived from VisualModel
sebsjames Mar 8, 2026
6fa7c60
Modularizes VectorVisual
sebsjames Mar 8, 2026
0982102
Modularizes InstancedScatterVisual
sebsjames Mar 8, 2026
ada6c9c
MOdularize EyeVisual and SphereVisual
sebsjames Mar 8, 2026
90aa679
Modularize NormalsVisual, VerticesVisual, all towards compiling antpov
sebsjames Mar 8, 2026
76778bd
Makes some colourmaps into modules to sidestep gcc-15 errors
sebsjames Mar 9, 2026
b25cdf1
Uses ifstream and fstream
sebsjames Mar 9, 2026
54f394a
cstdint for uint8_t
sebsjames Mar 9, 2026
6cc37aa
Undoes a wrong change
sebsjames Mar 9, 2026
4c5d9d6
Changes for g++. location of nlohmann makes a difference. g++ didn't …
sebsjames Mar 9, 2026
e865b46
Modularizes geodesic visual
sebsjames Mar 9, 2026
b8e5a1e
fixes
sebsjames Mar 9, 2026
91dd350
Trivial
sebsjames Mar 9, 2026
550b6a9
Latest maths
sebsjames Mar 9, 2026
904d742
Change wording a little
sebsjames Mar 10, 2026
c27b917
Re-word
sebsjames Mar 10, 2026
ac07304
Latest fixes in maths, plus debug reduction
sebsjames Mar 10, 2026
ff245a9
Some type-based tweaks in maths
sebsjames Mar 10, 2026
3f0ec9e
place khrplatform.h in gl.h
sebsjames Mar 10, 2026
68ffd4e
Merge branch 'dev/modules' of github.com:sebsjames/mathplot into dev/…
sebsjames Mar 10, 2026
a1fbffe
Colourbar visual, plus some tweaks to rod.cpp
sebsjames Mar 10, 2026
c2696ec
Debug reduction
sebsjames Mar 10, 2026
ceffbea
Modularize rhombovisual
sebsjames Mar 10, 2026
0d290a8
Merge branch 'dev/modules' of github.com:sebsjames/mathplot into dev/…
sebsjames Mar 10, 2026
8a4f798
Gets the hexgrid example working
sebsjames Mar 12, 2026
e4a2ede
Makes showcase work
sebsjames Mar 12, 2026
5f37514
Changes necessary to compile all of antpov
sebsjames Mar 12, 2026
7b0c72f
Get the examples building with modularized mathconst and constexpr_math
sebsjames Mar 12, 2026
945ec32
Armadillo is gone!
sebsjames Mar 12, 2026
15e2e56
Updates to readmes with removal of armadillo
sebsjames Mar 12, 2026
59c256b
More readme
sebsjames Mar 12, 2026
df53337
Latest maths
sebsjames Mar 13, 2026
5a711bf
Adds a place for bug reproduction
sebsjames Mar 13, 2026
8cf53ca
Adds filenames
sebsjames Mar 13, 2026
c898a91
Back to tuple, see if g++16 fixed that
sebsjames Mar 13, 2026
c38c76f
Reverts last commit, g++16 still doesn't like that code. Will come ba…
sebsjames Mar 13, 2026
894c0fd
correct typed constants
sebsjames Mar 13, 2026
d094615
You don't need the constructor to demo the error
sebsjames Mar 13, 2026
babdbd6
Merge branch 'dev/modules' of github.com:sebsjames/mathplot into dev/…
sebsjames Mar 13, 2026
4c5b2b8
Adds ability to return to the previous viewing position after going i…
sebsjames Mar 13, 2026
5cacb85
Adds compilers that work
sebsjames Mar 14, 2026
ca673d7
Basic examples now build with import std;
sebsjames Mar 15, 2026
6325e8a
Notes on modules
sebsjames Mar 17, 2026
e6755a0
More notes on buildtimes
sebsjames Mar 17, 2026
d5d238b
Notes on header only build time
sebsjames Mar 17, 2026
19e39cb
Last bit of info about build times with and without modules
sebsjames Mar 17, 2026
9386b4f
More results
sebsjames Mar 17, 2026
a8d04ee
Last results for header only antpov
sebsjames Mar 17, 2026
7d52b5b
Un-import std;
sebsjames Mar 17, 2026
f55c43d
Comment out the C++23 import std; module stuff
sebsjames Mar 17, 2026
17950bf
Correct branch of maths
sebsjames Mar 17, 2026
5ee6b35
Correct maths commit
sebsjames Mar 17, 2026
5da8753
Merge pull request #138 from sebsjames/dev/modules_unimport_std
sebsjames Mar 17, 2026
eb46c9a
Notes about my modules experience
sebsjames Mar 17, 2026
a7c4835
Changes to modules readme
sebsjames Mar 17, 2026
c2e9da7
More modules readme tweaks
sebsjames Mar 17, 2026
aab53ae
More notes and links
sebsjames Mar 17, 2026
03ce4f7
Title
sebsjames Mar 17, 2026
9a29d48
What I'll do now
sebsjames Mar 17, 2026
ecfbe9a
Last changes to readme modules
sebsjames Mar 17, 2026
1e1a7a0
Splits Ommatidium definition into its own little module
sebsjames Mar 18, 2026
d7063c5
Latest maths, incl an update to hdfdata
sebsjames Mar 19, 2026
117e1b5
Use updated module names from maths (.cppm suffix)
sebsjames Mar 20, 2026
56526bd
Convert modules to .cppm suffix
sebsjames Mar 20, 2026
85aa9f0
Definitions in here have gone to sm::grid
sebsjames Mar 20, 2026
f0f8494
Typo
sebsjames Mar 20, 2026
d3c5e11
Refactor headers to .hpp to show they're not going to be modules
sebsjames Mar 20, 2026
8afdd78
A new scheme to set up the modules variables
sebsjames Mar 20, 2026
2329acd
Can now have extra examples
sebsjames Mar 20, 2026
d2acadd
Updates to config (making it a module) don't affect the current build
sebsjames Mar 23, 2026
48eed83
maths is all modules now
sebsjames Mar 23, 2026
1715a48
Enables modular build of model_crawler example
sebsjames Mar 24, 2026
97a30a4
Adds the rosenbrock example
sebsjames Mar 25, 2026
5381db6
Changes after de-camelcasing sebsjames/maths
sebsjames Mar 27, 2026
5da3ca9
scaling_function was de-camelCased
sebsjames Mar 27, 2026
2dce8b4
Adds a reinitColours for rodVisual
sebsjames Mar 27, 2026
785ecc1
Adds a colour match convenience function
sebsjames Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "maths"]
path = maths
url = https://github.com/sebsjames/maths
[submodule "json"]
path = json
url = https://github.com/nlohmann/json
75 changes: 51 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
cmake_minimum_required(VERSION 3.14)
project(mathplot)
# 3.28.5: C++20 modules support 3.30 gives C++23 import std;
cmake_minimum_required(VERSION 3.28.5)

# For future import std; support
# set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")

project(mathplot LANGUAGES CXX C)
# Note that the project version is encoded in mplot/version.h and not in this CMakeLists.txt

message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS " (This can be changed with `cmake -DCMAKE_INSTALL_PREFIX=/some/place`")

#
# The base C++ version in mathplot is current C++-17 but I am considering C++20 or 23
# We're firmly at C++20.
#
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Add our cmake directory and our submodule maths's cmake dir to cmake modules path
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

# For future import std; support
# set(CMAKE_CXX_EXTENSIONS ON)
# Tell CMake that we explicitly want `import std`. This will initialize the
# property on all targets declared after this to 1
# set(CMAKE_CXX_MODULE_STD 1)

include(CheckIncludeFileCXX) # CHECK_INCLUDE_FILE_CXX will be used in later scripts

Expand All @@ -25,7 +38,7 @@ endif()

# Add the host definition to CXXFLAGS along with other switches
if (APPLE)
set(CMAKE_CXX_FLAGS "-Wall -g -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -O3")
else()
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES MSVC)
# Set flags for Windows.
Expand All @@ -34,25 +47,20 @@ else()
# /Zc:__cplusplus ensures __cplusplus define does not lie
# /constexpr:steps is equivalent to -fconstexpr-steps or -fconstexpr-ops-limit
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
set(CMAKE_CXX_FLAGS "-DNOMINMAX /EHsc /Zc:__cplusplus /constexpr:steps500000000")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX /EHsc /Zc:__cplusplus /constexpr:steps500000000")
else()
set(CMAKE_CXX_FLAGS "-DNOMINMAX /EHsc /Zc:__cplusplus /clang:-fconstexpr-steps=500000000")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX /EHsc /Zc:__cplusplus /clang:-fconstexpr-steps=500000000")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES Intel)
# To use Intel compiler, you can call cmake as: `cmake -DCMAKE_CXX_COMPILER=icpc ..` or `CXX=icpc cmake ..`
message(WARNING "Intel compiler has not been tested for some time")
set(CMAKE_CXX_FLAGS "-Wall -g -std=c++20 -xHOST -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -std=c++20 -xHOST -O3")
else() # GCC or Clang
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
# Add compiler version check, to ensure gcc is version 11 or later.
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
message(FATAL_ERROR "GCC version must be at least 11")
else()
message(STATUS "GCC version ${CMAKE_CXX_COMPILER_VERSION} OK!")
endif()
message(WARNING "GCC probably won't work, try clang-20")
endif()
set(COMPREHENSIVE_WARNING_FLAGS "-Wall -Wextra -Wpedantic -pedantic-errors -Werror -Wfatal-errors -Wno-psabi")
set(CMAKE_CXX_FLAGS "-g ${COMPREHENSIVE_WARNING_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${COMPREHENSIVE_WARNING_FLAGS} -O3")
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
# Make it possible to compile complex constexpr functions (gcc only)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconstexpr-ops-limit=5000000000")
Expand Down Expand Up @@ -126,16 +134,11 @@ find_package(HDF5)
if(HDF5_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HDF5_DEFINITIONS}")
endif()
find_package(Armadillo)

include_directories(${OPENGL_INCLUDE_DIR})
if(HDF5_FOUND)
include_directories(${HDF5_INCLUDE_DIR})
endif()
if(ARMADILLO_FOUND)
# Two possible values for the armadillo include dirs
include_directories(${ARMADILLO_INCLUDE_DIR} ${ARMADILLO_INCLUDE_DIRS})
endif()
include_directories(${GLFW3_INCLUDE_DIR})

# New, text rendering dependencies
Expand All @@ -155,7 +158,9 @@ else()
endif()

# Use packaged nlohmann json
find_package(nlohmann_json REQUIRED)
# find_package(nlohmann_json REQUIRED)
# Now nlohmann is submoduled to get an up-to-date version (for C++ modules)
include_directories("${PROJECT_SOURCE_DIR}/json/include")

# If Qt5 is present, then some optional Qt examples will be compiled
find_package(Qt5 QUIET COMPONENTS Gui Core Widgets)
Expand All @@ -181,6 +186,20 @@ if (NOT HAVE_RAPIDXML)
include_directories("${PROJECT_SOURCE_DIR}/include/rapidxml-1.13")
endif() # else we have it in a directory included by default in the path

#
# sebsjames/maths module groups
#

# Include maths module defs
include(${PROJECT_SOURCE_DIR}/maths/cmake/module_definitions.cmake)
setup_module_variables_for_maths (${PROJECT_SOURCE_DIR}/maths)

# Include our own module defs
include(${PROJECT_SOURCE_DIR}/cmake/module_definitions.cmake)
setup_module_variables_for_mathplot_maths (${PROJECT_SOURCE_DIR}/maths)
setup_module_variables_for_mathplot (${PROJECT_SOURCE_DIR})


# All the mathplot headers are here
add_subdirectory(mplot)

Expand All @@ -191,6 +210,12 @@ if(BUILD_TESTS)
add_subdirectory(tests)
endif(BUILD_TESTS)

option(BUILD_BUGREP "Build bugrep" OFF)
if(BUILD_BUGREP)
# bug reproduction
add_subdirectory(bugrep)
endif(BUILD_BUGREP)

# incbin for Visual Studio; code-generation for colour tables
option(BUILD_UTILS "Build developer utils" OFF)
if(BUILD_UTILS)
Expand All @@ -202,10 +227,12 @@ endif(BUILD_UTILS)
add_subdirectory(fonts)

# Example code (you can also see tests/ for examples)
option(BUILD_EXAMPLES_EXTRA "Build extra examples" OFF)
option(BUILD_EXAMPLES "Build examples" ON)
if(BUILD_EXAMPLES)
if(BUILD_EXAMPLES OR BUILD_EXAMPLES_EXTRA)
add_subdirectory(examples)
endif(BUILD_EXAMPLES)
endif(BUILD_EXAMPLES OR BUILD_EXAMPLES_EXTRA)


# Additional examples (requires BUILD_EXAMPLES ON)
option(BUILD_DOC_SCREENSHOTS "Build documentation screenshot examples" OFF)
Expand Down
29 changes: 13 additions & 16 deletions README.build.linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ program and a C++ compiler which can compile c++-20 code.

## *Required*: Install dependencies

mathplot code depends on OpenGL, Freetype and glfw3. Armadillo and HDF5 are optional dependencies which you may need. Armadillo is required if you use the `sm::bezcurve` class or any of the classes `sm::hexgrid`/`mplot::ReadCurve`/`sm::cartgri`d (which all use `sm::bezcurvepath` and hence `sm::bezcurve`). HDF5 is required if you use the `sm::hdfdata` wrapper class, or if you want to compile `sm::hexgrid`/`sm::cartgrid` with built-in `save()` and `load()` functions.
mathplot code depends on OpenGL, Freetype and glfw3. HDF5 is an optional dependency which you may need. HDF5 is required if you use the `sm::hdfdata` wrapper class, or if you want to compile the `hexgrid_hdf` module which provides `save()` and `load()` functions.

### Package-managed dependencies for Ubuntu/Debian

To install the visualization dependencies on Ubuntu or Debian Linux:

```sh
sudo apt install build-essential cmake git \
nlohmann-json3-dev librapidxml-dev \
sudo apt install build-essential cmake ninja git \
librapidxml-dev \
freeglut3-dev libglu1-mesa-dev libxmu-dev libxi-dev \
libglfw3-dev libfreetype-dev

# nlohmann-json3-dev was removed as I have to bundle a very up to date version for C++ modules support
```
For the optional dependencies it's:
```sh
sudo apt install libarmadillo-dev libhdf5-dev qtcreator qtbase5-dev libwxgtk3.2-dev libegl-dev libgbm-dev
sudo apt install libhdf5-dev qtcreator qtbase5-dev libwxgtk3.2-dev libegl-dev libgbm-dev
```
* Armadillo. Only required if you use the ```sm::bezcurve``` class.
* HDF5 library. Required if you use the wrapper class ```sm::hdfdata``` or any of the classes that make use of `sm::hdfdata` (```sm::hexgrid```,```sm::cartgrid```,```sm::anneal```). Their tests and examples should all compile if the libraries are detected and be omitted if not.
* Qt library. Installing qtcreator will bring in the Qt5 libraries that are used to compile some Qt-mathplot example programs. It almost certainly possible to install *only* the Qt5 Core, Gui and Widgets libraries, but that hasn't been verified. On recent Ubuntu systems, you may well need qtbase5-dev to get the cmake scripts to `find_package(Qt5...)`.
* WxWindows. libwxgtk3.2-dev (you'll need Ubuntu 23.04+) will enable the compilation of mathplot-wxWidgets example programs.
Expand All @@ -38,18 +37,16 @@ sudo apt install libarmadillo-dev libhdf5-dev qtcreator qtbase5-dev libwxgtk3.2-

### Package-managed dependencies for Arch Linux

On Arch Linux, all required dependencies except Armadillo are available in the official repository. They can be installed as follows:
On Arch Linux, all required dependencies are available in the official repository. They can be installed as follows:

```shell
sudo pacman -S vtk lapack blas freeglut glfw-wayland nlohmann-json
sudo pacman -S vtk lapack blas freeglut glfw-wayland # nlohmann-json
# Optional:
sudo pacman -S hdf5
```

**Note:** Specify `glfw-x11` instead of `glfw-wayland` if you use X.org.

Then, optionally, install [Armadillo](https://aur.archlinux.org/packages/armadillo/) from AUR.

## *Optional*: Build mathplot examples or tests

To build the mathplot example programs, it's the usual CMake process:
Expand All @@ -60,18 +57,18 @@ git clone https://github.com/sebsjames/mathplot.git
cd mathplot
mkdir build
cd build
cmake ..
make -j$(nproc)
cmake .. -GNinja
ninja
# I usually place the mathplot directory inside the code repository I'm working
# on, I call this 'in-tree mathplot', but you can also have the headers in
# /usr/local/include (control location with the usual CMAKE_INSTALL_PREFIX) if you install:
# sudo make install
# sudo ninja install
```
### Building test programs (or NOT building the examples)

By default, the example programs are built with the call to `make`, but unit test programs are not. To build test programs, and control whether example programs are compiled, use the cmake flags `BUILD_TESTS` and `BUILD_EXAMPLES`, changing your cmake line to:
By default, the example programs are built with the call to `ninja`, but unit test programs are not. To build test programs, and control whether example programs are compiled, use the cmake flags `BUILD_TESTS` and `BUILD_EXAMPLES`, changing your cmake line to:
```sh
cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=OFF # Build tests but not examples
cmake .. -GNinja -DBUILD_TESTS=ON -DBUILD_EXAMPLES=OFF # Build tests but not examples
# ...etc
```

Expand All @@ -82,7 +79,7 @@ as g++-11 or clang, then you just change the cmake call in the recipe
above. It becomes:

```sh
CXX=g++-11 cmake .. -DBUILD_TESTS=ON
CXX=g++-16 cmake .. -DBUILD_TESTS=ON
```
To run the test suite, use the `ctest` command in the build directory or `make test`.

Expand Down
49 changes: 5 additions & 44 deletions README.build.mac.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ command line tools, then install the Mac ports installation package.
Finally, use Mac ports to install the rest of the dependencies:

```sh
sudo port install cmake armadillo nlohmann-json
sudo port install cmake
```

*Be aware that if you have conflicting versions of any of the
Expand All @@ -63,8 +63,7 @@ compile glfw3 by hand.

It's much cleaner to build each of the dependencies by hand. That
means first installing cmake, which I do with a binary package from
https://cmake.org/download/, and then compiling hdf5 and
armadillo (all of which support a cmake build process).
https://cmake.org/download/, and then compiling hdf5.

After downloading and installing cmake using the MacOS installer, I
add these lines to ~/.zprofile so that I can type cmake at the terminal:
Expand All @@ -80,31 +79,8 @@ The mathplot github actions for mac runners use brew to install
dependencies. The command for the basic dependencies is

```sh
brew install libomp glfw armadillo hdf5 nlohmann-json
```

#### Armadillo

Armadillo is a library for matrix manipulation. The only place it's used in
mathplot is within the Bezier curve code,
sm::bezcurve. This code is used in the sm::hexgrid classes. If your programs won't use Bezier curve code, then you don't need Armadillo. It *is* required to compile some of mathplot's test programs though.

Download a package - I downloaded
armadillo-9.900.3.tar.xz, though older versions back to 8.400.0 should
work.

```sh
mkdir -p ~/src
cd ~/src
tar xvf path/to/downloaded/armadillo-9.900.3.tar.xz
cd armadillo-9.900.3
mkdir build
cd build
cmake ..
# or optionally: cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_OSX_DEPLOYMENT_TARGET=10.14
# which will set the install locn and get the code compiled for targets as old as mac 10.14
make
sudo make install
brew install libomp glfw hdf5 # nlohmann-json
# nlohmann-json was removed as I have to bundle a very up to date version for C++ modules support
```

#### HDF5
Expand Down Expand Up @@ -133,8 +109,7 @@ If present, the Qt5 components Core, Gui and Widgets components are used to comp

### Common manual dependency builds

Whether or not you used mac ports to install hdf5 and
armadillo, glfw3 also needs to be built separately (I've not investigated
Whether or not you used mac ports to install hdf5, glfw3 also needs to be built separately (I've not investigated
whether there is a mac ports version of glfw).

#### glfw3
Expand All @@ -153,20 +128,6 @@ make
sudo make install
```

#### nlohmann json

You'll need a package of nlohmann json.

```sh
sudo brew install nlohmann-json
```
```sh
sudo port install nlohmann-json
```

Or install manually from https://github.com/nlohmann/json


## Build mathplot on Mac

To build mathplot itself, it's the usual CMake process:
Expand Down
14 changes: 7 additions & 7 deletions README.cmake.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Building your code with mathplot

These instructions will be a little out of date now we build with C++ 20 modules.

## Dependencies

First, ensure you have the necessary dependencies installed. Classes in mathplot use nlohmann-json, rapidxml, Armadillo, OpenGL, Freetype, glfw3 and HDF5.
First, ensure you have the necessary dependencies installed. Classes in mathplot use nlohmann-json (submoduled), rapidxml, OpenGL, Freetype, glfw3 and HDF5.
You won't necessarily need all of these; it depends on which classes you will use (see [here](https://github.com/sebsjames/mathplot/blob/main/README.coding.md#linking-a-mathplot-program) for details).
For most visualisation, you only need OpenGL, Freetype and glfw3 and the header files for nlohmann-json.
For most visualisation, you only need OpenGL, Freetype and glfw3.
Platform-specific instructions can be found in the files [README.build.linux.md](https://github.com/sebsjames/mathplot/blob/main/README.build.linux.md), [README.build.mac.md](https://github.com/sebsjames/mathplot/blob/main/README.build.mac.md) and [README.build.windows.md](https://github.com/sebsjames/mathplot/blob/main/README.build.windows.md).

## Three necessities to build
Expand All @@ -15,7 +17,7 @@ to tell it: **1**) What compiler flags to add to the
compiler command line, including a directive to say where the fonts
that mathplot will compile into your binaries (if you're using
mplot::Visual) are located. **2**) Where the mathplot headers (in *mplot/*) are
to be found. **3**) which libraries to link to.
to be found. **3**) which modules to build and which libraries to link to.

While you can install mathplot headers (and fonts) into a chosen
location (/usr/local by default) we recommend that you just clone a
Expand Down Expand Up @@ -75,14 +77,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMPLOT_FONTS_DIR=\"\\\"/usr/local/share
```cmake
# Find the libraries which will be needed
find_package(HDF5 REQUIRED) # Only required if you used sm::hdfdata
find_package(Armadillo REQUIRED) # Only required if you use the sm::bezcurve classes or sm::hexgrid/sm::cartgrid
find_package(OpenGL REQUIRED) # This, glfw3, Freetype and nlohmann-json are required for mplot::Visual
find_package(glfw3 3.3 REQUIRED)
find_package(Freetype REQUIRED)
find_package(nlohmann-json REQUIRED)

# Define collections of includes for the dependencies
set(MPLOT_INC_CORE ${ARMADILLO_INCLUDE_DIR} ${ARMADILLO_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR})
set(MPLOT_INC_CORE ${HDF5_INCLUDE_DIR})
set(MPLOT_INC_GL ${OPENGL_INCLUDE_DIR} ${GLFW3_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIRS})
include_directories(${MPLOT_INC_CORE} ${MPLOT_INC_GL})

Expand All @@ -104,7 +104,7 @@ classes you use from mathplot, you'll need to link to some or all
of these:

```cmake
set(MPLOT_LIBS_CORE ${ARMADILLO_LIBRARY} ${ARMADILLO_LIBRARIES} ${HDF5_C_LIBRARIES})
set(MPLOT_LIBS_CORE ${HDF5_C_LIBRARIES})
set(MPLOT_LIBS_GL OpenGL::GL Freetype::Freetype glfw)
target_link_libraries(myprogtarget ${MPLOT_LIBS_CORE} ${MPLOT_LIBS_GL})
```
Expand Down
Loading
Loading