build: Split up features into separate libraries
This makes it much more obvious when a feature is missing for a user.
Change-Id: Ibb17d7ab1f185a1976a32f48933c01a252450dd1
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include-dl/meson.build b/include-dl/meson.build
new file mode 100644
index 0000000..c2a2862
--- /dev/null
+++ b/include-dl/meson.build
@@ -0,0 +1,5 @@
+stdplus_headers += include_directories('.')
+
+install_headers(
+ 'stdplus/dl.hpp',
+ subdir: 'stdplus')
diff --git a/include/stdplus/dl.hpp b/include-dl/stdplus/dl.hpp
similarity index 100%
rename from include/stdplus/dl.hpp
rename to include-dl/stdplus/dl.hpp
diff --git a/include-fd/meson.build b/include-fd/meson.build
new file mode 100644
index 0000000..33d021e
--- /dev/null
+++ b/include-fd/meson.build
@@ -0,0 +1,12 @@
+stdplus_headers += include_directories('.')
+
+install_headers(
+ 'stdplus/fd/create.hpp',
+ 'stdplus/fd/dupable.hpp',
+ 'stdplus/fd/gmock.hpp',
+ 'stdplus/fd/impl.hpp',
+ 'stdplus/fd/intf.hpp',
+ 'stdplus/fd/managed.hpp',
+ 'stdplus/fd/mmap.hpp',
+ 'stdplus/fd/ops.hpp',
+ subdir: 'stdplus/fd')
diff --git a/include/stdplus/fd/create.hpp b/include-fd/stdplus/fd/create.hpp
similarity index 100%
rename from include/stdplus/fd/create.hpp
rename to include-fd/stdplus/fd/create.hpp
diff --git a/include/stdplus/fd/dupable.hpp b/include-fd/stdplus/fd/dupable.hpp
similarity index 100%
rename from include/stdplus/fd/dupable.hpp
rename to include-fd/stdplus/fd/dupable.hpp
diff --git a/include/stdplus/fd/gmock.hpp b/include-fd/stdplus/fd/gmock.hpp
similarity index 100%
rename from include/stdplus/fd/gmock.hpp
rename to include-fd/stdplus/fd/gmock.hpp
diff --git a/include/stdplus/fd/impl.hpp b/include-fd/stdplus/fd/impl.hpp
similarity index 100%
rename from include/stdplus/fd/impl.hpp
rename to include-fd/stdplus/fd/impl.hpp
diff --git a/include/stdplus/fd/intf.hpp b/include-fd/stdplus/fd/intf.hpp
similarity index 100%
rename from include/stdplus/fd/intf.hpp
rename to include-fd/stdplus/fd/intf.hpp
diff --git a/include/stdplus/fd/managed.hpp b/include-fd/stdplus/fd/managed.hpp
similarity index 100%
rename from include/stdplus/fd/managed.hpp
rename to include-fd/stdplus/fd/managed.hpp
diff --git a/include/stdplus/fd/mmap.hpp b/include-fd/stdplus/fd/mmap.hpp
similarity index 100%
rename from include/stdplus/fd/mmap.hpp
rename to include-fd/stdplus/fd/mmap.hpp
diff --git a/include/stdplus/fd/ops.hpp b/include-fd/stdplus/fd/ops.hpp
similarity index 100%
rename from include/stdplus/fd/ops.hpp
rename to include-fd/stdplus/fd/ops.hpp
diff --git a/include-uring/meson.build b/include-uring/meson.build
new file mode 100644
index 0000000..91b426f
--- /dev/null
+++ b/include-uring/meson.build
@@ -0,0 +1,5 @@
+stdplus_headers += include_directories('.')
+
+install_headers(
+ 'stdplus/io_uring.hpp',
+ subdir: 'stdplus')
diff --git a/include/stdplus/io_uring.hpp b/include-uring/stdplus/io_uring.hpp
similarity index 100%
rename from include/stdplus/io_uring.hpp
rename to include-uring/stdplus/io_uring.hpp
diff --git a/include/meson.build b/include/meson.build
index 5d870ac..5c6ea12 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -1,29 +1,4 @@
-stdplus_headers = include_directories('.')
-
-if has_dl
- install_headers(
- 'stdplus/dl.hpp',
- subdir: 'stdplus')
-endif
-
-if has_fd
- install_headers(
- 'stdplus/fd/create.hpp',
- 'stdplus/fd/dupable.hpp',
- 'stdplus/fd/gmock.hpp',
- 'stdplus/fd/impl.hpp',
- 'stdplus/fd/intf.hpp',
- 'stdplus/fd/managed.hpp',
- 'stdplus/fd/mmap.hpp',
- 'stdplus/fd/ops.hpp',
- subdir: 'stdplus/fd')
-endif
-
-if has_io_uring
- install_headers(
- 'stdplus/io_uring.hpp',
- subdir: 'stdplus')
-endif
+stdplus_headers = [include_directories('.')]
install_headers(
'stdplus/cancel.hpp',
diff --git a/meson.build b/meson.build
index 7d7e0c8..8659147 100644
--- a/meson.build
+++ b/meson.build
@@ -39,6 +39,16 @@
endif
subdir('include')
+if has_dl
+ subdir('include-dl')
+endif
+if has_fd
+ subdir('include-fd')
+endif
+if has_io_uring
+ subdir('include-uring')
+endif
+
subdir('src')
build_tests = get_option('tests')
diff --git a/src/meson.build b/src/meson.build
index 1492655..3f1021e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -79,3 +79,36 @@
description: 'C++ helper utilities',
version: meson.project_version(),
requires: stdplus_reqs)
+
+if has_dl
+ stdplus_dl_dep = stdplus_dep
+
+ import('pkgconfig').generate(
+ stdplus_lib,
+ name: 'stdplus-dl',
+ description: 'C++ helper utilities',
+ version: meson.project_version(),
+ requires: stdplus_reqs)
+endif
+
+if has_fd
+ stdplus_fd_dep = stdplus_dep
+
+ import('pkgconfig').generate(
+ stdplus_lib,
+ name: 'stdplus-fd',
+ description: 'C++ helper utilities',
+ version: meson.project_version(),
+ requires: stdplus_reqs)
+endif
+
+if has_io_uring
+ stdplus_io_uring_dep = stdplus_dep
+
+ import('pkgconfig').generate(
+ stdplus_lib,
+ name: 'stdplus-io_uring',
+ description: 'C++ helper utilities',
+ version: meson.project_version(),
+ requires: stdplus_reqs)
+endif
diff --git a/test/meson.build b/test/meson.build
index 2634c45..0317121 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -29,10 +29,20 @@
'util/string',
]
+gtest_deps = [
+ stdplus_dep,
+ gtest,
+ gmock,
+]
+
if has_dl
gtests += [
'dl',
]
+
+ gtest_deps += [
+ stdplus_dl_dep,
+ ]
elif build_tests.enabled()
error('Not testing libdl feature')
else
@@ -49,6 +59,10 @@
'fd/mock',
'fd/ops',
]
+
+ gtest_deps += [
+ stdplus_fd_dep,
+ ]
elif build_tests.enabled()
error('Not testing file descriptor feature')
else
@@ -59,6 +73,10 @@
gtests += [
'io_uring',
]
+
+ gtest_deps += [
+ stdplus_io_uring_dep,
+ ]
elif build_tests.enabled()
error('Not testing io_uring feature')
else
@@ -70,7 +88,7 @@
test(t, executable(t.underscorify(), t + '.cpp',
build_by_default: false,
implicit_include_directories: false,
- dependencies: [stdplus_dep, gtest, gmock]))
+ dependencies: gtest_deps))
endforeach
endif