Currently CMake scripts will generate both dynamic and static libraries
at the same time. However, CMake recommends using BUILD_SHARED_LIBS to
build either dynamic or static library, which is enforced by vcpkg.
Use BUILD_SHARED_LIBS to build one library type at a time, so that
developers can use vcpkg manifest mechanism to install Argtable3.
We also add namespace (argtable3::) to the package and generate CMake
config version file (Argtable3ConfigVersion.cmake), which can be used to determine the library version in find_package().
Add a CMake setting ARGTABLE3_LONG_ONLY to use getopt_long_only in
dynamic and static libraries. By default it is OFF. To turn on the
setting:
$ cmake -DARGTABLE3_LONG_ONLY=ON ..
Add a C macro ARG_LONG_ONLY to use getopt_long_only in ordinary source
distribution and amalgamation distribution.
resolves#57
Switching to FreeBSD getopt library can resolve two issues:
1. FreeBSD getopt always uses the 2-Clause BSD, which is compatible
to GPL. (Although NetBSD has switched to the 2-Clause BSD in
2008.)
2. FreeBSD getopt_long provides getopt_long_only, which is critical
for developers who want to follow the command-line syntax
convention, which uses a single '-' character for long options.
resolves: #54#56
We didn't notice that using add_compile_definitions will force
developers upgrading their CMake to 3.12. Go back using the old
add_definitions() so we can keep using CMake 3.0.
resolves: #48
When we build with AddressSanitizer (ASan) in GCC, we can see a lot of memory
leaks and a buffer overflow issue in unit tests and arg_file implementation.
The root cause of memory leaks in unit tests is that, we never care about
releasing memory in unit test code. Besides, the semantics of CuSuiteAddSuite()
makes releasing a test suite very difficult. By fixing CuSuiteAddSuite() and
carefully releasing memory in unit tests, memory leaks are resolved.
The root cause of the buffer overflow issue in arg_file is that, we mix pointer
and array operations together. By using strlen(result) instead of result[1] to
determine the string length, the buffer overflow issue is resolved.
resolves: #46
With the new CMake script, we can generate four types of library:
shared, static, original source, and amalgamation source. We add tests
to make sure all library types can work correctly.
We've also solved several issues related to Linux/Windows build errors.
The CMake script can generate the amalgamation distribution, and we can
choose whether to use the amalgamation or not.
This is a huge commit since the last one. Here are the major changes:
- Add original source files and the amalgamation generator utilities
- Add dynamic string utilities (arg_dstr) used to generator output
- Add hash table utilities (arg_hashtable) used to store sub-commands
- Add utilities (arg_cmd) used to implement the sub-command mechanism
- Use clang-format to unify the coding style
- Add new unit tests
- Fix warnings under strict compiler settings in VC and GCC
- Add ARG_REPLACE_GETOPT to choose the built-in or system getopt
- Add utilities to generate help messages
- Cleanup the mess after various pull requests