* meson: Add a Meson based build system
This is primarily intended to be useful for projects using Meson wishing
to consume cxxopts as a subproject. By hosting the files upstream users
get the benefit of automatic parity with the CMake based install
provided by an OS vendor or distribution.
The implementation attempts to mirror the CMake build as much as
possible, with the exception of generating the cmake-config files, which
Meson doesn't currently support. It uses a small python script to parse
the cxxopts.hpp header to extract the version, due to a concious design
decision of Meson to leave such complex logic to external scripting
languages like Python.
* CI: add basic Meson testing
I've tried to be a bit more minimal here than the CMake tests are, since
there's already a good cross section of testing there. For Meson, I just
want to touch test each of the major platforms to ensure that it works
* fix: Use non deprecated upload-artifact action version
* fix: Use branch name in build workflow, use latest checkout action, use cd bulid as job steps doesn't preserve current directories between themselves.
* fix: remove non-existent main branch, remove deprecated ubuntu-20, removed deprecated macos-11 and macos-12, setup g++-9 and g++-10 if not exists, use latest checkout action
* Move `result` up and return it
This allows `gcc` to elide the copy in the return and keeps it from
warning with `-Wnvro` enabled.
* Remove harmful dtor definition
The definition of the dtor is not necessary and actually harmful since
the definition of a class's implicit copy constructor is deprecated if
that class has a user-declared constructor as of C++11. Compilers can
warn about this with `-Wdeprecated`.
---------
Co-authored-by: Christoph Weiss <weiss@wsoptics.de>
* cmake: set PROJECT_DESCRIPTION and PROJECT_HOMEPAGE_URL after project()
Otherwise they are set to an empty string.
* cmake: set the pkg-config URL field
Since the information is already there to set it.
* cmake: use CMAKE_INSTALL_DATAROOTDIR if CMAKE_LIBRARY_ARCHITECTURE is unset
This causes files on NixOS to be put in the proper architecture
independent place, which otherwise was selecting the architecture
dependent location.
* cmake: Properly set pkg-config requires when configured with ICU
In this case the pkg-config file needs to set icu-cu in the `Required`
field, and needs to add the flag `-DCXXOPTS_USE_UNICODE` to the `Cflags`
field.
* cmake: cxxopts is not arch independent when built with ICU support
Since it links to an architecture dependent ICU
Fixes#290.
Checking for overflow should be done before integer overflows.
There are two checks:
(result > limit / base) is used for limits greater than rounded up to base,
e.g. for 65535 it will activate for 65540 and higher.
(result * base > limit - digit) is used for limit+1 to limit+n below
next base rounded number, e.g. 65536 up to 65539.