Those local variables will only be used in that folder and its subfolders but the cache variables propagate into the whole project. Those then get used by other dependencies
As 2.1.1 is the latest release and the referenced googletest commit does not exist using any other googletest version results in a build failure, either of:
CMake Error at external/googletest/googletest/cmake/internal_utils.cmake:332 (install):
install TARGETS given no ARCHIVE DESTINATION for static library target
"gtest".
at configure time, or similar at install time:
CMake Error at external/googletest/googlemock/cmake_install.cmake:41 (file):
file INSTALL given no DESTINATION
Look at https://github.com/simongog/libdivsufsort/blob/22e6b23e619ff50fd086844b6e618d53ca9d53bd/CMakeLists.txt#L30-L48 This sets cache variables to empty, then (if empty) sets local variables to a default but leaving the cache variables empty.
Those local variables will only be used in that folder and its subfolders but the cache variables propagate into the whole project. Those then get used by other dependencies
As 2.1.1 is the latest release and the referenced googletest commit does not exist using any other googletest version results in a build failure, either of:
at configure time, or similar at install time:
This is due them using the proper https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html ending up with empty paths
Solution:
CMAKE_INSTALL_*
variablesinclude(GNUInstallDirs)
insteadRelated: GMock should not be build and GTest should not be installed. So
should be set before including the subdirectory and I recommend including the root folder of googletest and
googletest/googletest
as done in master.