summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kms++/inc/kms++/pixelformats.h12
-rw-r--r--meson.build14
2 files changed, 23 insertions, 3 deletions
diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h
index 6049c20..fac9c0f 100644
--- a/kms++/inc/kms++/pixelformats.h
+++ b/kms++/inc/kms++/pixelformats.h
@@ -15,7 +15,12 @@ constexpr uint32_t str_to_fourcc(const std::string_view fourcc)
return fourcc[0] | (fourcc[1] << 8) | (fourcc[2] << 16) | (fourcc[3] << 24);
}
-constexpr std::string fourcc_to_str(uint32_t fourcc)
+#if HAS_CONSTEXPR_STR
+constexpr
+#else
+static inline
+#endif
+std::string fourcc_to_str(uint32_t fourcc)
{
char buf[4] = {
(char)((fourcc >> 0) & 0xff),
@@ -146,7 +151,10 @@ struct PixelFormatPlaneInfo {
};
struct PixelFormatInfo {
- constexpr PixelFormatInfo(const std::string_view name,
+ #if HAS_CONSTEXPR_STR && HAS_CONSTEXPR_VEC
+ constexpr
+ #endif
+ PixelFormatInfo(const std::string_view name,
const std::string_view drm_fourcc,
const std::string_view v4l2_4cc,
PixelColorType color,
diff --git a/meson.build b/meson.build
index 9789e8c..cec41f3 100644
--- a/meson.build
+++ b/meson.build
@@ -22,6 +22,18 @@ if cpp.has_argument('-Wno-c99-designator')
]
endif
+if cpp.compiles('#include <string>\n constexpr bool test(const std::string& x) { return x.empty(); }')
+ add_global_arguments('-DHAS_CONSTEXPR_STR', language : 'cpp')
+else
+ message('Compiler does not support constexpr strings')
+endif
+
+if cpp.compiles('#include <vector>\n constexpr bool test(const std::vector<int>& x) { return x.empty(); }')
+ add_global_arguments('-DHAS_CONSTEXPR_VEC', language : 'cpp')
+else
+ message('Compiler does not support constexpr vectors')
+endif
+
add_project_arguments(cpp_arguments, language : 'cpp')
libfmt_dep = dependency('fmt')
@@ -33,7 +45,7 @@ if libdrmomap_dep.found()
endif
if get_option('libutils')
- add_global_arguments('-DHAS_KMSXXUTIL', language : 'cpp')
+ add_global_arguments('-DHAS_KMSXXUTIL', language : 'cpp')
endif
subdir('kms++')