From 34c28b81328f84d5e0d9d22db3b63d8e982deeea Mon Sep 17 00:00:00 2001 From: Leon Merten Lohse Date: Tue, 24 Sep 2024 09:56:49 +0200 Subject: [PATCH 1/3] Build: add meson configuration for system-wide installation and pkg-config support --- meson.build | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/meson.build b/meson.build index e17d616..13d5501 100644 --- a/meson.build +++ b/meson.build @@ -4,6 +4,20 @@ project('libnpy', license : 'MIT' ) +# Allow system-wide installation +libnpy_subdir = 'libnpy' +libnpy_headers = ['include/npy.hpp'] +install_headers(libnpy_headers, subdir : libnpy_subdir) + +# Allow auto-configuration with pkg-config +pkg = import('pkgconfig') +pkg.generate( + name : meson.project_name(), + subdirs : [libnpy_subdir], + description : 'A lightweight library for reading and writing NumPy-compatible .npy files', + ) + +# Make this library usable as a Meson subproject libnpy_dep = declare_dependency( include_directories : include_directories('include') ) From 0cd5fd342087210d05034519738be9838d310e76 Mon Sep 17 00:00:00 2001 From: Leon Merten Lohse Date: Tue, 24 Sep 2024 10:08:38 +0200 Subject: [PATCH 2/3] Explain installation in README.md --- README.md | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1e17b7b..c331ef6 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,33 @@ It also allows *reading* .npy files, although only a very limited subset of data - floating point - complex floating point (std::complex, ...) -## Usage -libnpy is a header only library. You only need to download `npy.hpp` into your include path. Neither special compiler flags nor a specific build system are required. +## Installation +libnpy is a header-only library. You only need to download `npy.hpp` into your include path and `#include "npy.hpp"`. Neither special compiler flags nor a specific build system are required. + + +### (Optional) Meson subproject +For projects using meson as build system, libnpy can be readily included as a subproject. -Optional: If you use meson, you can use the provided `meson.build` file to declare the dependency on libnpy. +After cloning or unpacking libnpy into the `subprojects` folder, the dependency can be declared in the `meson.build` file as +``` +libnpy_subproj = subproject('libnpy') +libnpy_dep = libnpy_subproj.get_variable('libnpy_dep') +``` -The API has changed in the last release. The old C-style API is still available, but might get removed in the future. +### (Optional) System-wide installation +libnpy can also be installed system-wide. This requires the meson build system. From within the sources call +``` +meson setup builddir +cd builddir +meson compile +meson install +``` +This will copy the `npy.hpp` into `include/libnpy/` relative to your install prefix (/usr/local/ by default) and generate and install a matching `libnpy.pc`. + +The required include path can then be obtained with `pkg-config -cflags libnpy`. + +## Usage +The API has changed in the 1.0 release. The old C-style API is still available, but might get removed in the future. ### Reading data: ```c++ From c7b018c31f2ddae5d73f158f1207a2116b13eac9 Mon Sep 17 00:00:00 2001 From: Leon Merten Lohse Date: Tue, 24 Sep 2024 10:11:53 +0200 Subject: [PATCH 3/3] docs: remove unnecessary compile command --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index c331ef6..3028510 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ libnpy can also be installed system-wide. This requires the meson build system. ``` meson setup builddir cd builddir -meson compile meson install ``` This will copy the `npy.hpp` into `include/libnpy/` relative to your install prefix (/usr/local/ by default) and generate and install a matching `libnpy.pc`.