Fix format string mismatches where the format specifier doesn't match
the argument type:
- Change %d to %u for unsigned int/uint32_t arguments
- Change %u to %d for signed int arguments
- Add casts where needed for printf family functions
- Use PRIu64/PRIi64 for uint64_t/int64_t arguments
Fix -Wformat-nonliteral warnings
Add TIFF_ATTRIBUTE((__format__(__printf__, N, 0))) to functions that
accept format strings as parameters (va_list style). The 0 indicates
no variadic arguments to check since the format is validated at the
call site.
* Split extra-warnings into extra-warnings and broken-warnings
* extra-warnings initially only uses -pedantic -Wextra
* Warnings will be moved from broken-warnings to extra-warnings
once the CI builds have proved them safe to use
Add two new CMake options to help maintain C++ compatibility:
1. cxx-compat-warnings: Enables -Wc++-compat flag (GCC/Clang) which
warns about using C++ keywords as identifiers and some enum/int
conversions. This is limited and won't catch all issues.
2. cxx-compat-mode: Compiles C source files as C++17 using -x c++
(GCC/Clang) or /TP (MSVC). This catches all C++ incompatibilities
as compile errors, including:
- implicit void* to typed pointer conversions
- register storage class (removed in C++17)
- goto/switch jumping over variable initialization
- enum arithmetic and implicit conversions
Usage:
cmake -Dcxx-compat-warnings=ON .. # Light checking
cmake -Dcxx-compat-mode=ON .. # Full C++ compilation
Link with CMATH_LIBRARIES instead of CMath::CMath. While this
will still be exported, it will be available on the host system.
Port of original commit:
67f73084ca
co-authored: Roger Leigh <rleigh@codelibre.net>
Autotools sets WORDS_BIGENDIAN via tif_config.h, but the CMake equivalent
in tif_config.h.cmake.in is a no-op; CMake passes the define on the
compiler command line instead. For consistency, have CMake set the define
via tif_config.h.
- Move in tiffvers.h from .\libtiff source directory to .\libtiff build directory.
- Remove unused version information from tif_config.h
- With every CMake build the version defines (e.g. 4.5.1) within tiffvers.h are consistently updated from configure.ac. The version release-date is taken from file RELEASE-DATE.
- The files VERSION and RELEASE-DATE are only updated with a special CMake target build: cmake --build . --target tiff_release.
- For autotools, version information is updated from configure.ac with ./autogen.sh. LIBTIFF_RELEASE_DATE is taken form file RELEASE-DATE.
- ./configure generates tiffvers.h with the cached version information and LIBTIFF_RELEASE_DATE.
- "make release" updates tiffvers.h and VERSION file with cached version info and RELEASE-DATE file and tiffves.h with the current date.
There are CMake issues if the library is not included in the environment path and only set with CMake -D option.
- For FindDeflate.cmake, FindJBIG.cmake, FindLERC.cmake, FindWebP.cmake, FindZSTD.cmake:
Set IMPORTED_LOCATION (without debug or release) if neither <library>_LIBRARY_RELEASE nor <library>_LIBRARY_DEBUG were set.
- FindDeflate.cmake: Correct code to retrieve library version information from libdeflate.h
- FindLERC.cmake version string return added.
Recent versions of CMake have improved support for including
dependencies, using the FetchContent module, which allows a dependency
to be imported as a subproject and then later found automatically by
calls to `find_package`.
This change makes libtiff's CMake better behaved when used as a
sub-project:
- CMake has a single global namespace for all target names in all
sub-projects. This commit renames the following CMake targets:
- port -> tiff_port
- mkg3states -> tiff_mkg3states
- faxtable -> tiff_faxtable
- release -> tiff_release
- When building TIFF as a sub-project, it is not normally useful to
create install rules for its targets. This commit adds a
`tiff-install` option that controls whether the install rules are
added and defaults to OFF when libtiff is included as a sub-project.
- Previously, libtiff set `BUILD_SHARED_LIBS` to ON by default. With
this commit, that default is only set if libtiff is the top-level
project.
- When using `find_package(TIFF)`, the targets `TIFF::TIFF` and
`TIFF::CXX` are defined. This commit makes libtiff itself define
those targets as aliases, to allow other cmake projects to use
either `find_package` or `FetchContent` interchangeably.
- Adds ZSTD_HAVE_DECOMPRESS_STREAM variable which may be set to bypass
`check_symbol_exists` call. Fixes
https://gitlab.com/libtiff/libtiff/-/issues/472.
Replace all CMAKE_INSTALL_FULL_<DIR> with CMAKE_INSTALL_<DIR> to allow CPack setting CMAKE_INSTALL_PREFIX
Signed-off-by: Timothy Lyanguzov <timothy.lyanguzov@sap.com>