diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2023-12-01 11:19:02 -0600 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2023-12-01 12:20:49 -0600 |
commit | 461d00fcd5c5842b9a56f7462d55d46bf21163cc (patch) | |
tree | eb51c2daa0a09eda5fe1ed3d329899eeef6ff159 | |
parent | 2a99ee9ee67a7dea87dc4bddbcbc36a98e7c12c2 (diff) |
Handle build with older versions of GCC
Older versions of GCC (prior to 9.1) did not put the `std::filesystem`
support directly into libstdcpp, but in a separate `libstdc++fs`. Add
meson logic to detect if an extra linker flag is necessary.
Fixes #223.
Tested on AlmaLinux 8 which uses GCC-8.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
-rw-r--r-- | meson.build | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/meson.build b/meson.build index ecc012f..93acd40 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,7 @@ config = configuration_data() i18n = import('i18n') cc = meson.get_compiler('c') +cxx = meson.get_compiler('cpp') ############################################################################### # Project configuration @@ -47,6 +48,19 @@ if not xdgmime_found endif ############################################################################### +# Check if GCC needs -lstdc++fs (before 9.1) + +if not cxx.links(''' + #include <filesystem> + int main() { + return std::filesystem::is_directory( + std::filesystem::status("/tmp")) ? 0 : 1; + } + ''', name: 'std++fs-check') + add_project_link_arguments('-lstdc++fs', language : 'cpp') +endif + +############################################################################### # Dependencies config.set('HAVE_FDATASYNC', cc.has_function('fdatasync', prefix: '#include <unistd.h>')) |