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/
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

View File

@@ -18,18 +18,34 @@
# 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_project_arguments('-fvisibility=default', language: 'cpp')
logging_header_install_dir = get_option('header_install_dir') != '' \
? get_option('header_install_dir') / 'fourdst' / 'logging' \
: get_option('includedir') / 'fourdst' / 'logging'
if get_option('build_python')
local_py_install = import('python').find_installation('python3', pure: false)
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') != '' \
? get_option('header_install_dir') / 'fourdst' / 'vendor' \
: get_option('includedir') / 'fourdst' / 'vendor'
vendor_lib_dir = fourdst_pkg / 'lib' / 'vendor'
vendor_header_dir = fourdst_pkg / 'include' / '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('src')
@@ -44,7 +60,7 @@ endif
if get_option('pkg_config')
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.generate(
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('build_tests', type: 'boolean', value: true, description: 'generate unit tests (uses gtest)')
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('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

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