googletest icon indicating copy to clipboard operation
googletest copied to clipboard

[Bug]: CMake FetchContent_* does not work with GTest as dependency name on Windows

Open ObiWahn opened this issue 2 years ago • 7 comments

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

ObiWahn avatar Oct 03 '23 11:10 ObiWahn

relates to

  • https://github.com/google/googletest/issues/2457
  • https://gitlab.kitware.com/cmake/cmake/-/issues/25294

ObiWahn avatar Oct 03 '23 11:10 ObiWahn

CMake is entirely community supported. We have no plans to fix this issue ourselves, but would consider accepting a pull request.

dinord avatar Oct 10 '23 15:10 dinord

yes, i reproduce this issue, i strongly recommend to notify user in docs if not fixed.

llcxiongmao avatar Feb 05 '24 17:02 llcxiongmao

even more, we just prohibit 'gtest' as name in FetchContent and give an error message for user.

llcxiongmao avatar Feb 05 '24 18:02 llcxiongmao

https://github.com/google/googletest/pull/4466

danfabo avatar Feb 14 '24 20:02 danfabo

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

hks2002 avatar Feb 22 '24 04:02 hks2002