FetchContent_* does not work with GTest as dependency name on Windows
CMake FetchContent_* does not work with GTest as dependency name. If the dependency name is changed to googletest or to foobar everything works as expected. This is very unfortunate because GTest is used in the find_package command of CMake and if this fails the FetchContent mechanism can be used as fallback.
- https://github.com/ObiWahn/googletest-CMake-FetchContent <-- my stupid test repo
- https://github.com/google/googletest/issues/4384 <-- same issue on the googletest github repo.
From my experience it is often a forth and back between project and no side wants to take responsibility. I think it would be best handled on this side, as Google does not really care about CMake, because they use blaze/bazel internally and You can solve it most probably better. Futhermore googletest is a very prominent project and seeing that find_package
and FetchContent_Declare
use the same dependency names would be a good example of how things should be.
Once this is fixed this documentation http://google.github.io/googletest/quickstart-cmake.html
should be updated on their side.
-
https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/FindGTest.cmake <-- This basically defines how to find the project. Maybe an alias/symlink to Findgoogletest could be added as (bad) alternative.
-
https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/GoogleTest.cmake <-- Here is some extra work related to google test. The existence of the file shows that googletest is somewhat important the CMake maintainers. But I would prefer if the simple things (find_package/FetchContent_*) would work before I get additional macros.
It is no world moving problem. It will mostly hit people on github or in shituations where they have no or minimal control over their build environment. But github is where people look at the code of others and copy ideas. In the past there was so much horrible CMake code and only books like Professional CMake had in the last few yeas a positive impact. Now please move this in the right direction and help the google maintainers to avoid more horrible code:)