From 82428f9e6ed0ebb1dea647460271a0650fc132a6 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Thu, 11 Jun 2026 10:55:15 -0400 Subject: [PATCH] build(meson): more robust python version building --- Doxyfile | 2 +- meson.build | 20 +++++++++++++++++++- meson_options.txt | 3 +-- src/composition/meson.build | 17 ++++++----------- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Doxyfile b/Doxyfile index 590daa9..5962bf0 100644 --- a/Doxyfile +++ b/Doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = fourdst::libcomposition # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v2.4.5 +PROJECT_NUMBER = v2.4.6 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewers a diff --git a/meson.build b/meson.build index 195718a..55fd423 100644 --- a/meson.build +++ b/meson.build @@ -18,13 +18,31 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # *********************************************************************** # -project('libcomposition', 'cpp', version: 'v2.4.5', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') +project('libcomposition', 'cpp', version: 'v2.4.6', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') # Add default visibility for all C++ targets add_project_arguments('-fvisibility=default', language: 'cpp') # Disable shadow warnings add_project_arguments('-Wno-shadow', language: 'cpp') +if get_option('build_python') + local_py_install = import('python').find_installation('python3', pure: false) + fourdst_pkg = local_py_install.get_install_dir() / 'fourdst' + + composition_libdir = fourdst_pkg / 'lib' + composition_header_install_dir = fourdst_pkg / 'include' / 'fourdst' / 'composition' + + vendor_lib_dir = fourdst_pkg / 'lib' / 'vendor' + vendor_header_dir = fourdst_pkg / 'include' / 'fourdst' / 'vendor' + message('Installing libcomposition in python mode. Install locations are...') +else + composition_libdir = get_option('libdir') + composition_header_install_dir = get_option('includedir') / 'fourdst' / 'composition' + message('Installing libcomposition in non python (normal) mode. Install locations are...') +endif +message(' Libraries: ' + composition_libdir) +message(' Headers: ' + composition_header_install_dir) + cpp = meson.get_compiler('cpp') subdir('build-config') diff --git a/meson_options.txt b/meson_options.txt index 8624d2f..7c20d8b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,5 +2,4 @@ option('pkg_config', type: 'boolean', value: true, description: 'generate pkg-co option('build_tests', type: 'boolean', value: true, description: 'build unit tests (uses gtest)') option('build_examples', type: 'boolean', value: true, description: 'build example programs') option('build_benchmarks', type: 'boolean', value: false, description: 'build benchmark programs') -option('lib_install_dir', type: 'string', value: '', description: 'Override install dir for the shared library (used by the fourdst umbrella to place libs inside the Python package in wheel builds). Empty = default libdir.') -option('header_install_dir', type: 'string', value: '', description: 'Override the header install root (used by the fourdst umbrella to place headers inside the Python package in wheel builds). Empty = default includedir.') +option('build_python', type: 'boolean', value: false, description: 'Build in python mode. Note that this does not generate a wheel; rather, this is the appropriate option to turn on when packaging this component inside of a wheel.') diff --git a/src/composition/meson.build b/src/composition/meson.build index 115b3fd..7351a06 100644 --- a/src/composition/meson.build +++ b/src/composition/meson.build @@ -37,14 +37,13 @@ dependencies = [ xxhash_dep ] -fourdst_component_libdir = get_option('lib_install_dir') != '' ? get_option('lib_install_dir') : get_option('libdir') - libcomposition = library('composition', - composition_sources, - cpp_args: ['-fvisibility=default'], - dependencies: dependencies, - install: true, - install_dir: fourdst_component_libdir) + composition_sources, + cpp_args: ['-fvisibility=default'], + dependencies: dependencies, + install: true, + install_dir: composition_libdir +) composition_dep = declare_dependency( @@ -53,10 +52,6 @@ composition_dep = declare_dependency( sources: composition_sources, ) -composition_header_install_dir = get_option('header_install_dir') != '' \ - ? get_option('header_install_dir') / 'fourdst' / 'composition' \ - : get_option('includedir') / 'fourdst' / 'composition' - # Make headers accessible composition_headers = files( 'include/fourdst/composition/composition.h',