From e88d89e71e06528b6386e7e57ca3ed654ba3b345 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Thu, 11 Jun 2026 10:56:54 -0400 Subject: [PATCH] build(meson): more robust python build mode --- Doxyfile | 2 +- build-config/CLI11/meson.build | 4 ++-- build-config/reflect-cpp/meson.build | 8 ++----- build-config/tomlpp/meson.build | 2 +- meson.build | 32 ++++++++++++++++++++++------ meson_options.txt | 1 + src/config/meson.build | 4 ++-- 7 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Doxyfile b/Doxyfile index 852530c..a32423d 100644 --- a/Doxyfile +++ b/Doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = libconfig # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v2.2.8 +PROJECT_NUMBER = v2.2.9 # 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/build-config/CLI11/meson.build b/build-config/CLI11/meson.build index 9e66bb6..a30049d 100644 --- a/build-config/CLI11/meson.build +++ b/build-config/CLI11/meson.build @@ -4,5 +4,5 @@ cli11_dep = cli11_proj.get_variable('CLI11_dep') cli11_headers = cli11_proj.get_variable('cli11_headers') cli11_impl_headers = cli11_proj.get_variable('cli11_impl_headers') -install_headers(cli11_headers, install_dir: config_header_root / 'fourdst' / 'vendor' / 'CLI') -install_headers(cli11_impl_headers, install_dir: config_header_root / 'fourdst' / 'vendor' / 'CLI' / 'impl') \ No newline at end of file +install_headers(cli11_headers, install_dir: vendor_header_dir / 'CLI') +install_headers(cli11_impl_headers, install_dir: vendor_header_dir / 'CLI' / 'impl') \ No newline at end of file diff --git a/build-config/reflect-cpp/meson.build b/build-config/reflect-cpp/meson.build index 8f8691c..4ff368e 100644 --- a/build-config/reflect-cpp/meson.build +++ b/build-config/reflect-cpp/meson.build @@ -16,15 +16,11 @@ reflect_cpp_sources = files( reflect_cpp_include_dirs = include_directories('include') -reflect_cpp_install_dir = get_option('lib_install_dir') != '' \ - ? get_option('lib_install_dir') / 'vendor' \ - : get_option('libdir') / 'fourdst' / 'vendor' - reflect_cpp_library = static_library('reflect_cpp', reflect_cpp_sources, include_directories: [reflect_cpp_include_dirs, tomlpp_inc_dir], install: true, - install_dir: reflect_cpp_install_dir) + install_dir: vendor_lib_dir) reflect_cpp_dep = declare_dependency( link_with: reflect_cpp_library, @@ -33,6 +29,6 @@ reflect_cpp_dep = declare_dependency( install_subdir( 'include', - install_dir: config_header_root / 'fourdst' / 'vendor', + install_dir: vendor_header_dir, strip_directory: true, ) diff --git a/build-config/tomlpp/meson.build b/build-config/tomlpp/meson.build index bf76b5e..d8201ce 100644 --- a/build-config/tomlpp/meson.build +++ b/build-config/tomlpp/meson.build @@ -2,7 +2,7 @@ tomlpp_inc_dir = include_directories('vendor/include') install_subdir( 'vendor/include', - install_dir: config_header_root / 'fourdst' / 'vendor', + install_dir: vendor_header_dir, strip_directory: true, exclude_files: ['meson.build'], ) diff --git a/meson.build b/meson.build index 196a5ce..e02d4c7 100644 --- a/meson.build +++ b/meson.build @@ -18,14 +18,35 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # *********************************************************************** # -project('libconfig', ['cpp', 'c'], version: 'v2.2.8', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') +project('libconfig', ['cpp', 'c'], version: 'v2.2.9', 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') -config_header_root = get_option('header_install_dir') != '' \ - ? get_option('header_install_dir') \ - : get_option('includedir') +if get_option('build_python') + local_py_install = import('python').find_installation('python3', pure: false) + fourdst_pkg = local_py_install.get_install_dir() / 'fourdst' + + config_libdir = fourdst_pkg / 'lib' + config_header_install_dir = fourdst_pkg / 'include' / 'fourdst' / 'config' + + vendor_lib_dir = fourdst_pkg / 'lib' / 'vendor' + vendor_header_dir = fourdst_pkg / 'include' / 'fourdst' / 'vendor' + + message('Installing libconfig in python mode. Install locations are...') +else + config_libdir = get_option('libdir') + config_header_install_dir = get_option('includedir') / 'fourdst' / 'config' + + vendor_lib_dir = get_option('libdir') / 'fourdst' / 'vendor' + vendor_header_dir = get_option('includedir') / 'fourdst' / 'vendor' + + message('Installing libconfig in non python (normal) mode. Install locations are...') +endif +message(' Package Libraries: ' + config_libdir) +message(' Package Headers: ' + config_header_install_dir) +message(' Vendor Libraries: ' + vendor_lib_dir) +message(' Vendor Headers: ' + vendor_header_dir) cpp = meson.get_compiler('cpp') subdir('build-config') @@ -42,8 +63,7 @@ endif if get_option('pkg_config') message('Generating pkg-config file for libconfig...') - vendor_inc_flags = '-I${includedir}' / 'fourdst' / 'vendor' - + vendor_inc_flags = '-I' + get_option('prefix') / vendor_header_dir pkg = import('pkgconfig') pkg.generate( name: 'libconfig', diff --git a/meson_options.txt b/meson_options.txt index 9d605e0..ce93d98 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,4 +3,5 @@ option('build_tests', type: 'boolean', value: true, description: 'Build unit and option('build_examples', type: 'boolean', value: true, description: 'Build simple example 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/config/meson.build b/src/config/meson.build index 174eb59..a6e2e2a 100644 --- a/src/config/meson.build +++ b/src/config/meson.build @@ -18,5 +18,5 @@ config_exception_headers = files( 'include/fourdst/config/exceptions/exceptions.h', ) -install_headers(config_headers, install_dir: config_header_root / 'fourdst' / 'config') -install_headers(config_exception_headers, install_dir: config_header_root / 'fourdst' / 'config' / 'exceptions') \ No newline at end of file +install_headers(config_headers, install_dir: config_header_install_dir) +install_headers(config_exception_headers, install_dir: config_header_install_dir / 'exceptions') \ No newline at end of file