build(meson): more robust python build mode

This commit is contained in:
2026-06-11 10:56:54 -04:00
parent 92795f8f5a
commit e88d89e71e
7 changed files with 35 additions and 18 deletions

View File

@@ -48,7 +48,7 @@ PROJECT_NAME = libconfig
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # 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 # 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 # for a project that appears at the top of each page and should give viewers a

View File

@@ -4,5 +4,5 @@ cli11_dep = cli11_proj.get_variable('CLI11_dep')
cli11_headers = cli11_proj.get_variable('cli11_headers') cli11_headers = cli11_proj.get_variable('cli11_headers')
cli11_impl_headers = cli11_proj.get_variable('cli11_impl_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_headers, install_dir: vendor_header_dir / 'CLI')
install_headers(cli11_impl_headers, install_dir: config_header_root / 'fourdst' / 'vendor' / 'CLI' / 'impl') install_headers(cli11_impl_headers, install_dir: vendor_header_dir / 'CLI' / 'impl')

View File

@@ -16,15 +16,11 @@ reflect_cpp_sources = files(
reflect_cpp_include_dirs = include_directories('include') 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_library = static_library('reflect_cpp',
reflect_cpp_sources, reflect_cpp_sources,
include_directories: [reflect_cpp_include_dirs, tomlpp_inc_dir], include_directories: [reflect_cpp_include_dirs, tomlpp_inc_dir],
install: true, install: true,
install_dir: reflect_cpp_install_dir) install_dir: vendor_lib_dir)
reflect_cpp_dep = declare_dependency( reflect_cpp_dep = declare_dependency(
link_with: reflect_cpp_library, link_with: reflect_cpp_library,
@@ -33,6 +29,6 @@ reflect_cpp_dep = declare_dependency(
install_subdir( install_subdir(
'include', 'include',
install_dir: config_header_root / 'fourdst' / 'vendor', install_dir: vendor_header_dir,
strip_directory: true, strip_directory: true,
) )

View File

@@ -2,7 +2,7 @@ tomlpp_inc_dir = include_directories('vendor/include')
install_subdir( install_subdir(
'vendor/include', 'vendor/include',
install_dir: config_header_root / 'fourdst' / 'vendor', install_dir: vendor_header_dir,
strip_directory: true, strip_directory: true,
exclude_files: ['meson.build'], exclude_files: ['meson.build'],
) )

View File

@@ -18,14 +18,35 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 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 default visibility for all C++ targets
add_project_arguments('-fvisibility=default', language: 'cpp') add_project_arguments('-fvisibility=default', language: 'cpp')
config_header_root = get_option('header_install_dir') != '' \ if get_option('build_python')
? get_option('header_install_dir') \ local_py_install = import('python').find_installation('python3', pure: false)
: get_option('includedir') 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') cpp = meson.get_compiler('cpp')
subdir('build-config') subdir('build-config')
@@ -42,8 +63,7 @@ endif
if get_option('pkg_config') if get_option('pkg_config')
message('Generating pkg-config file for libconfig...') 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 = import('pkgconfig')
pkg.generate( pkg.generate(
name: 'libconfig', name: 'libconfig',

View File

@@ -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('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('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('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.')

View File

@@ -18,5 +18,5 @@ config_exception_headers = files(
'include/fourdst/config/exceptions/exceptions.h', 'include/fourdst/config/exceptions/exceptions.h',
) )
install_headers(config_headers, install_dir: config_header_root / 'fourdst' / 'config') install_headers(config_headers, install_dir: config_header_install_dir)
install_headers(config_exception_headers, install_dir: config_header_root / 'fourdst' / 'config' / 'exceptions') install_headers(config_exception_headers, install_dir: config_header_install_dir / 'exceptions')