[Bug]: CMake FetchContent_* does not work with GTest as dependency name on Windows
Describe the issue
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 GTets is used in the find_package command of CMake and if this fails the FetchContent mechanism can be used as fallback. But not on windows as you can see here:
https://github.com/ObiWahn/googletest-CMake-FetchContent/pull/1
Steps to reproduce the problem
https://github.com/ObiWahn/googletest-CMake-FetchContent/pull/1/files
What version of GoogleTest are you using?
v.1.14.0
What operating system and version are you using?
windows
What compiler and version are you using?
msvc / clang
What build system are you using?
cmake 3.27.6
Additional context
No response
relates to
- https://github.com/google/googletest/issues/2457
- https://gitlab.kitware.com/cmake/cmake/-/issues/25294
CMake is entirely community supported. We have no plans to fix this issue ourselves, but would consider accepting a pull request.
yes, i reproduce this issue, i strongly recommend to notify user in docs if not fixed.
even more, we just prohibit 'gtest' as name in FetchContent and give an error message for user.
https://github.com/google/googletest/pull/4466
See the difference by using name gtest and googletest gtest/GTest:
[cmake] -- gtest_SOURCE_DIR: D:/GitHub/ttt/build/_deps/gtest-src
[cmake] -- googletest_SOURCE_DIR:
googletest:
[cmake] -- gtest_SOURCE_DIR: D:/GitHub/ttt/build/_deps/googletest-src/googletest
[cmake] -- googletest_SOURCE_DIR: D:/GitHub/ttt/build/_deps/googletest-src