summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormrsmidge <smidge@xsco.net>2020-08-16 21:30:58 +0100
committermrsmidge <smidge@xsco.net>2020-08-16 21:30:58 +0100
commit401794f3a1a0581ab131ad704598664ab0d70fcb (patch)
tree3792e13aff77a38bfb8dd9d572bec2087377f192 /include
parent7880bfe9cbcfda05a38a74e6a53f1ce5e8cc8b6d (diff)
Introduce build-time generated config.hpp file
Both meson and CMake build detect support for std::optional<T> or its experimental equivalent.
Diffstat (limited to 'include')
-rw-r--r--include/djinterop/config.hpp.in (renamed from include/djinterop/config.hpp)6
-rw-r--r--include/djinterop/meson.build20
-rw-r--r--include/meson.build4
3 files changed, 29 insertions, 1 deletions
diff --git a/include/djinterop/config.hpp b/include/djinterop/config.hpp.in
index 97260cc..b558501 100644
--- a/include/djinterop/config.hpp
+++ b/include/djinterop/config.hpp.in
@@ -46,4 +46,10 @@
#endif // DJINTEROP_SOURCE
#define DJINTEROP_LOCAL DJINTEROP_SYMBOL_LOCAL
+// Symbols defined after this point represent the environment at the time
+// that this library was built. The environment when this library is used must
+// be compatible in order to use the library successfully.
+#cmakedefine DJINTEROP_STD_OPTIONAL
+#cmakedefine DJINTEROP_STD_EXPERIMENTAL_OPTIONAL
+
#endif // DJINTEROP_CONFIG_HPP
diff --git a/include/djinterop/meson.build b/include/djinterop/meson.build
new file mode 100644
index 0000000..c43a0b2
--- /dev/null
+++ b/include/djinterop/meson.build
@@ -0,0 +1,20 @@
+# Generate config file based on build-time feature detection.
+# Note that most build configuration for public headers is handled in the
+# parent build file; this file exists solely because the `output` parameter
+# of configure_file() does not, at the time of writing (meson 0.55.0), support
+# writing the output file to a different directory.
+conf_data = configuration_data()
+if cpp_compiler.has_header('optional')
+ conf_data.set10('DJINTEROP_STD_OPTIONAL', true)
+endif
+if cpp_compiler.has_header('experimental/optional')
+ conf_data.set10('DJINTEROP_STD_EXPERIMENTAL_OPTIONAL', true)
+endif
+configure_file(
+ input: 'config.hpp.in',
+ output: 'config.hpp',
+ configuration: conf_data,
+ format: 'cmake',
+ install_dir: get_option('includedir') + '/djinterop'
+)
+
diff --git a/include/meson.build b/include/meson.build
index ee89840..f43c8e8 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -1,6 +1,8 @@
+# Used only to generate config.hpp in the nested include dir.
+subdir('djinterop')
+
djinterop_header_files = [
'djinterop/album_art.hpp',
- 'djinterop/config.hpp',
'djinterop/crate.hpp',
'djinterop/database.hpp',
'djinterop/djinterop.hpp',