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().
The CMake scripts depend on the version.tag file in the project root to
determine the library version. However, current release archives do not
have this file.
Add version.tag to release archives, so developers and vcpkg can use the
file to generate correct Argtable3ConfigVersion.cmake and DLL version
resource.
In MinGW64/MinGW32 environment, gcc will give warnings when we use 'char'
as an array subscript, and when we use C11 functions, such as getenv_s().
We use explicit casting to resolve the array subscript issues, and check
if the build environment supports C11 before calling C11 functions.
resolves#61
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
The setjmp function used in the trex_compile function will cause errors
while building with -Wall in GCC for ARM. By disabling optimizations
for the trex_compile function, the compiler (gcc 9.2) will put the
variable on the stack and resolve the errors.
resolves#53
We enhance the build script (batch and bash), so it can generate
amalgamation distributions for both the UNIX and Windows platforms.
To generate a distribution for a specific version, first use make to
list all tags and check out the specified tag in the project root
directory:
$ make taglist
$ make co TAG=<tag>
Then go to the tools directory and run the script to generate tar.gz
for UNIX and generate zip for Windows:
$ cd .tag/<tag>/tools
$ ./build cleanall
$ ./build tar
$ ./build zip
Notice that this enhancement was added after the official release
v3.1.5.1c1bb23, so you need to specify a tag newer than v3.1.5.
resolves#43
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
It is annoying to make sure the Argtable3 shared library is properly
installed or in the same directory as the example binaries before
running them.
By making examples using the static library by default, we can make it
easy to run example applications, no matter where they are.
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
When we use strncpy and strncat, we have allocated one more byte for
the terminal NULL character. However, the GCC after version 8 will
report warnings (-Wstringop-truncation) even when we use strncpy and
strncat correctly. Replace strncpy and strncat with memcpy to avoid
these warnings.
With target_compile_definitions(argtable3 INTERFACE argtable3_IMPORTS)
in src/CMakeLists.txt, we no longer have to explicitly specify
-Dargtable3_IMPORTS.