meson: remove the subproject-based library checking

this is not idiomatic, and should not be done (and it did not even
work in the first place); meson is capable of building both
libraries via library() and then you can choose on commandline

it defaults to only shared, but we want both out of box, so specify
that
arm_linker_fix
Daniel Kolesa 2021-01-08 15:51:55 +01:00
parent 4801f0bdd8
commit f3e0033a06
1 changed files with 21 additions and 32 deletions

View File

@ -2,7 +2,7 @@ project(
'libucontext', 'libucontext',
'c', 'c',
meson_version : '>=0.55.0', meson_version : '>=0.55.0',
default_options: ['c_std=gnu99'], default_options: ['c_std=gnu99', 'default_library=both'],
version : run_command('head', files('VERSION')).stdout() version : run_command('head', files('VERSION')).stdout()
) )
@ -52,8 +52,7 @@ project_includes = [
] ]
build_args = [ build_args = [
'-D_BSD_SOURCE', '-D_BSD_SOURCE'
'-DPIC'
] ]
@ -85,39 +84,31 @@ endif
# ====== # ======
headers = include_directories(project_includes) headers = include_directories(project_includes)
is_subproject = meson.is_subproject()
# Build only static library if subproject
libucontext_target = both_libraries( libucontext_target = library(
'ucontext', 'ucontext',
project_source_files, project_source_files,
version: meson.project_version(), version: meson.project_version(),
install : not is_subproject, install : not meson.is_subproject(),
c_args : build_args, c_args : build_args,
pic: true, pic: true,
include_directories : headers, include_directories : headers,
) )
if is_subproject
libucontext_target = libucontext_target.get_static_lib()
endif
libucontext_dep = declare_dependency( libucontext_dep = declare_dependency(
include_directories: headers, include_directories: headers,
link_with : libucontext_target link_with : libucontext_target
) )
if build_posix if build_posix
libucontext_posix_target = both_libraries( libucontext_posix_target = library(
'ucontext_posix', 'ucontext_posix',
project_source_files + ['libucontext_posix.c'], project_source_files + ['libucontext_posix.c'],
version: meson.project_version(), version: meson.project_version(),
install : not is_subproject, install : not meson.is_subproject(),
c_args : build_args, c_args : build_args,
pic: true, pic: true,
include_directories : headers, include_directories : headers,
) )
if is_subproject
libucontext_posix_target = libucontext_posix_target.get_static_lib()
endif
libucontext_posix_dep = declare_dependency( libucontext_posix_dep = declare_dependency(
include_directories: headers, include_directories: headers,
link_with : libucontext_posix_target link_with : libucontext_posix_target
@ -128,7 +119,7 @@ endif
# Project # Project
# ======= # =======
if not is_subproject if not meson.is_subproject()
# Make this library usable from the system's # Make this library usable from the system's
# package manager. # package manager.
install_headers(project_headers, subdir : meson.project_name()) install_headers(project_headers, subdir : meson.project_name())
@ -148,7 +139,7 @@ endif
# ==== # ====
# TODO: meson.build for docs # TODO: meson.build for docs
if not is_subproject if not meson.is_subproject()
#subdir('docs') #subdir('docs')
endif endif
@ -156,7 +147,6 @@ endif
# Unit Tests # Unit Tests
# ========== # ==========
if not is_subproject
test('test_libucontext', test('test_libucontext',
executable( executable(
'test_libucontext', 'test_libucontext',
@ -175,4 +165,3 @@ if not is_subproject
) )
) )
endif endif
endif