Skip to content

Commit

Permalink
meson: Keep cpp23_args for clang
Browse files Browse the repository at this point in the history
  • Loading branch information
talisein committed Jul 12, 2024
1 parent e2a3b61 commit c05664d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ jobs:
- if: ${{ matrix.flavor == 'windows' }}
name: Configure Windows Latest
run: |
meson setup --warnlevel 3 --buildtype release --default-library static -Dcpp_std=vc++latest -Dcpp_eh=a -Dlibxml2:warning_level=0 -Dminiz:warning_level=0 -Dlibjpeg-turbo:warning_level=0 -Dcpp-httplib:cpp-httplib_openssl=disabled -Dlibxmlpp:build-tests=false -Dlibxml2:python=disabled -Dlibxml2:iconv=disabled --force-fallback-for libpng build
meson setup --warnlevel 3 --buildtype release -Dcpp_std=vc++latest --default-library static -Dcpp_eh=a -Dlibxml2:warning_level=0 -Dminiz:warning_level=0 -Dlibjpeg-turbo:warning_level=0 -Dcpp-httplib:cpp-httplib_openssl=disabled -Dlibxmlpp:build-tests=false -Dlibxml2:python=disabled -Dlibxml2:iconv=disabled --force-fallback-for libpng build
- name: Compile
run: ninja -C build
Expand Down
60 changes: 30 additions & 30 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('dregarnuhr', ['c', 'cpp'],
license : 'GPLv3+',
version : '1.5.10.0',
default_options : ['c_std=gnu17',
default_options : ['c_std=c17',
'cpp_std=c++23',
'buildtype=release',
'default_library=static',
Expand All @@ -12,37 +12,37 @@ if host_machine.system() == 'linux'
endif

cpp_compiler = meson.get_compiler('cpp')
if cpp_compiler.get_argument_syntax() == 'msvc'
else
if cpp_compiler.get_id() == 'clang'
cpp23_args += '-stdlib=libc++'
cpp23_args += '-fexperimental-library'
add_global_link_arguments('-stdlib=libc++', language: 'cpp')

if get_option('buildtype') == 'debug'
cpp23_args += '-gdwarf-4'
add_global_arguments('-gdwarf-4', language: 'c')
endif
endif
cpp23_args = []
if cpp_compiler.get_id() == 'clang'
cpp23_args += '-stdlib=libc++'
cpp23_args += '-fexperimental-library'
add_global_link_arguments('-stdlib=libc++', language: 'cpp')

if get_option('buildtype') == 'debug'
cpp23_args += '-gdwarf-4'
add_global_arguments('-gdwarf-4', language: 'c')
endif
endif

cpp_compiler.has_header_symbol('version', '__cpp_lib_filesystem', required: true)
cpp_compiler.has_header_symbol('version', '__cpp_lib_string_view', required: true)
cpp_compiler.has_header_symbol('version', '__cpp_lib_ranges', required: true)
cpp_compiler.has_header_symbol('version', '__cpp_lib_source_location', required: true)
cpp_compiler.has_header_symbol('version', '__cpp_concepts', required: true)
cpp_compiler.compute_int('__cpp_concepts', prefix: '#include<version>')
cpp_compiler.has_header_symbol('version', '__cpp_lib_integer_comparison_functions', required: true)
cpp_compiler.has_header_symbol('version', '__cpp_lib_expected', required: true)
cpp_compiler.has_header_symbol('version', '__cpp_size_t_suffix')
cpp_compiler.has_header_symbol('version', '__cpp_lib_ranges_zip')
cpp_compiler.has_header_symbol('version', '__cpp_lib_stacktrace')
cpp_compiler.has_header_symbol('version', '__cpp_lib_spanstream')
cpp_compiler.has_header_symbol('version', '__cpp_lib_flat_map')
cpp_compiler.has_header_symbol('version', '__cpp_lib_format')

has_chrono = 1 == cpp_compiler.compute_int('__cpp_lib_chrono >= 201907L', prefix: '#include<chrono>')
message('Adding cpp23 args: ', cpp23_args)
add_global_arguments(cpp23_args, language: 'cpp')

cpp_compiler.has_header_symbol('version', '__cpp_lib_filesystem', required: true, args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_string_view', required: true, args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_ranges', required: true, args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_source_location', required: true, args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_concepts', required: true, args: cpp23_args)
cpp_compiler.compute_int('__cpp_concepts', prefix: '#include<version>', args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_integer_comparison_functions', required: true, args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_expected', required: true, args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_size_t_suffix', args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_ranges_zip', args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_stacktrace', args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_spanstream', args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_flat_map', args: cpp23_args)
cpp_compiler.has_header_symbol('version', '__cpp_lib_format', args: cpp23_args)

has_chrono = 1 == cpp_compiler.compute_int('__cpp_lib_chrono >= 201907L', prefix: '#include<chrono>', args: cpp23_args)

# Fedora libxml++-devel. Ubuntu doesn't have a -5.0 package.
libxmlpp_dep = dependency('libxml++-5.0',
Expand Down Expand Up @@ -70,7 +70,7 @@ if not miniz_dep.found()
endif

# Unpackaged
if not cpp_compiler.has_header('outcome/outcome.hpp')
if not cpp_compiler.has_header('outcome/outcome.hpp', args: cpp23_args)
outcome_dep = dependency('outcome-2.0', fallback: ['outcome'])
else
outcome_dep = dependency('', required: false)
Expand Down
6 changes: 3 additions & 3 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ conf_data = configuration_data()
conf_data.set('IS_WINDOWS', host_machine.system() == 'windows' ? 'true' : 'false')
conf_data.set10('HAVE_CHRONO', has_chrono)

if cpp_compiler.has_header_symbol('ios', 'std::ios_base::noreplace')
if cpp_compiler.has_header_symbol('ios', 'std::ios_base::noreplace', args: cpp23_args)
conf_data.set('NOREPLACE', 'std::ios_base::noreplace')
elif cpp_compiler.has_header_symbol('ios', 'std::ios_base::__noreplace')
elif cpp_compiler.has_header_symbol('ios', 'std::ios_base::__noreplace', args: cpp23_args)
conf_data.set('NOREPLACE', 'std::ios_base::__noreplace')
elif cpp_compiler.has_header_symbol('ios', 'std::ios_base::_Noreplace')
elif cpp_compiler.has_header_symbol('ios', 'std::ios_base::_Noreplace', args: cpp23_args)
conf_data.set('NOREPLACE', 'std::ios_base::_Noreplace')
else
conf_data.set('NOREPLACE', 'std::ios_base::binary')
Expand Down
2 changes: 1 addition & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ namespace utils
[[nodiscard]] auto safe_int_cast(From from) -> std::remove_cvref_t<To> {
using namespace std::string_view_literals;
auto res = static_cast<std::remove_cvref_t<To>>(from);
if (!std::in_range<To>(from)) {
if (std::cmp_not_equal(res, from)) [[unlikely]] {
std::string error_message = utils::strcat("Trying to cast from ", from, " to a type that would become ", res);
if (std::cmp_greater(from, res)) {
throw std::overflow_error(error_message);
Expand Down

0 comments on commit c05664d

Please sign in to comment.