CMake 4.0 drops compatibility with versions older than 3.5, and warns
that compatibility with < 3.10 will be dropped in a "future version".
CMake 3.30 previously warned about dropping support for older than
3.5, which was changed in 3.31 to older than 3.10.
The recent PIC changes for the internal TinyXML2 somehow broke compiling
gtest_main on Windows:
extlib\googletest\googletest\src\gtest_main.cc(48): error C2491: 'main':
definition of dllimport function not allowed
Also disable gmock_main, since it depends on gtest_main.
We aren't actually using these, so it's not an issue.
(We implement our own main() in gtest_init.cpp.)
[extlib] CMakeLists.txt: Rename SET_EXTLIB_PROPERTIES_PIC() to
SET_EXTLIB_PROPERTIES_PIC_ONLY(), since SET_EXTLIB_PROPERTIES()
also sets POSITION_INDEPENDENT_CODE=TRUE.
Also use SET_EXTLIB_PROPERTIES_PIC_ONLY() for shared libraries that
may be installed, since we can't use SET_EXTLIB_PROPERTIES().
gcc-4.9 doesn't support std::is_trivially_copy_constructible<T> or
std::is_trivially_destructible<T>, so use __has_trivial_copy(T)
and __has_trivial_destructor(T) on old gcc.
It's not a perfect fix, but it gets the code to compile.
(I'm using Debian 8 to test big-endian using qemu-system-ppc.
Surprisingly, it's faster than Wii U Linux, even with all of
the CPU emulation overhead!)
CMAKE_DEBUG_POSTFIX wasn't being set, so the PDB filename ended up being
gtestpdb_debug_postfix-NOTFOUND.pdb.
Set CMAKE_DEBUG_POSTFIX="d" and CMAKE_RELEASE_POSTFIX="" when building
with MSVC. For other compilers, both are set to "".
gcc-11.1 complained about uninitialized variables, and googletest has
-Werror specified:
In file included from ../../extlib/googletest/googletest/src/gtest-all.cc:42:
../../extlib/googletest/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
../../extlib/googletest/googletest/src/gtest-death-test.cc:1301:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
1301 | StackLowerThanAddress(&dummy, &result);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../extlib/googletest/googletest/src/gtest-death-test.cc:1290:13: note: by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
1290 | static void StackLowerThanAddress(const void* ptr, bool* result) {
| ^~~~~~~~~~~~~~~~~~~~~
../../extlib/googletest/googletest/src/gtest-death-test.cc:1299:7: note: ‘dummy’ declared here
1299 | int dummy;
| ^~~~~
cc1plus: all warnings being treated as errors
This causes zlib, libpng, and possibly others to not export any symbols
in either the .a or .so on Linux, which makes them unusable.
CheckHiddenVisibility.cmake: New macro CHECK_HIDDEN_VISIBILITY().
Use this in the upper-level source directory to apply hidden visibility
to all subprojects. Used in src/CMakeLists.txt.
libromdata/tests/CMakeLists.txt:
- Link to gtest directly instead of ${GTEST_LIBRARY}.
- Removed INCLUDE_DIRECTORIES() for googletest, since it's added to
TARGET_INCLUDE_DIRECTORIES() by googletest's CMakeLists.txt.
extlib/googletest/googletest/CMakeLists.txt:
- Uncommented gtest_hide_internal_symbols.
Removed cmake/gtest.cmake, since it doesn't have anything useful other
than INCLUDE(CTest), which is now present in the top-level CMakeLists.txt.
Google Test will be used for implementing unit tests. The first set of
unit tests will be for testing RpPng with various PNG image formats.
The Google Test code is currently identical to the release archive,
except for the removal of .travis.yml and appveyor.xml.
CMakeLists.txt: Added CTest support. (see cmake/gtest.cmake)
extlibs/CMakeLists.txt: Only build googletest libraries if testing is
enabled and some project depends on them.