build(meson): more robust python build

This commit is contained in:
2026-06-11 11:01:05 -04:00
parent 8817be5831
commit 10d93fe4e7
5 changed files with 29 additions and 16 deletions

2
.gitignore vendored
View File

@@ -86,3 +86,5 @@ output/
.idea/ .idea/
scratch/ scratch/
subprojects/.wraplock

View File

@@ -21,5 +21,5 @@ if get_option('default_library') != 'static'
install_subdir(quill_headers, install_dir: vendor_logging_header_install_dir) install_subdir(quill_headers, install_dir: vendor_header_dir)
endif endif

View File

@@ -18,18 +18,34 @@
# 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('liblogging', 'cpp', version: 'v1.1.5', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') project('liblogging', 'cpp', version: 'v1.1.6', 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')
logging_header_install_dir = get_option('header_install_dir') != '' \ if get_option('build_python')
? get_option('header_install_dir') / 'fourdst' / 'logging' \ local_py_install = import('python').find_installation('python3', pure: false)
: get_option('includedir') / 'fourdst' / 'logging' fourdst_pkg = local_py_install.get_install_dir() / 'fourdst'
logging_libdir = fourdst_pkg / 'lib'
logging_header_install_dir = fourdst_pkg / 'include' / 'fourdst' / 'logging'
vendor_logging_header_install_dir = get_option('header_install_dir') != '' \ vendor_lib_dir = fourdst_pkg / 'lib' / 'vendor'
? get_option('header_install_dir') / 'fourdst' / 'vendor' \ vendor_header_dir = fourdst_pkg / 'include' / 'fourdst' / 'vendor'
: get_option('includedir') / 'fourdst' / 'vendor'
message('Installing liblogging in python mode. Install locations are...')
else
logging_libdir = get_option('libdir')
logging_header_install_dir = get_option('includedir') / 'fourdst' / 'logging'
vendor_lib_dir = get_option('libdir') / 'fourdst' / 'vendor'
vendor_header_dir = get_option('includedir') / 'fourdst' / 'vendor'
message('Installing liblogging in non python (normal) mode. Install locations are...')
endif
message(' Package Libraries: ' + logging_libdir)
message(' Package Headers: ' + logging_header_install_dir)
message(' Vendor Libraries: ' + vendor_lib_dir)
message(' Vendor Headers: ' + vendor_header_dir)
subdir('build-config') subdir('build-config')
subdir('src') subdir('src')
@@ -44,7 +60,7 @@ endif
if get_option('pkg_config') if get_option('pkg_config')
message('Generating pkg-config file for liblogging...') message('Generating pkg-config file for liblogging...')
vendor_inc_flags = '-I' + vendor_logging_header_install_dir vendor_inc_flags = '-I' + get_option('prefix') / vendor_header_dir
pkg = import('pkgconfig') pkg = import('pkgconfig')
pkg.generate( pkg.generate(
name: 'liblogging', name: 'liblogging',

View File

@@ -1,5 +1,4 @@
option('pkg_config', type: 'boolean', value: true, description: 'generate pkg-config file for liblogging (fourdst_liblogging.pc)') option('pkg_config', type: 'boolean', value: true, description: 'generate pkg-config file for liblogging (fourdst_liblogging.pc)')
option('build_tests', type: 'boolean', value: true, description: 'generate unit tests (uses gtest)') option('build_tests', type: 'boolean', value: true, description: 'generate unit tests (uses gtest)')
option('build_examples', type: 'boolean', value: true, description: 'generate example programs') option('build_examples', type: 'boolean', value: true, description: 'generate 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('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.')
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.')

View File

@@ -26,16 +26,12 @@ dependencies = [
quill_dep, quill_dep,
] ]
logging_lib_install_dir = get_option('lib_install_dir') != '' \
? get_option('lib_install_dir') \
: get_option('libdir')
liblogging = library('logging', liblogging = library('logging',
logging_sources, logging_sources,
include_directories: include_directories('include'), include_directories: include_directories('include'),
cpp_args: ['-fvisibility=default'], cpp_args: ['-fvisibility=default'],
install : true, install : true,
install_dir: logging_lib_install_dir, install_dir: logging_libdir,
dependencies: dependencies dependencies: dependencies
) )