filipdutescu / modern-cpp-template

A template for modern C++ projects using CMake, Clang-Format, CI, unit testing and more, with support for downstream inclusion.
The Unlicense
1.69k stars 214 forks source link

[BUG] Gmock target not found #36

Open radupaulstefan opened 2 years ago

radupaulstefan commented 2 years ago

Describe the bug Starting from fresh template, if use gmock option is selected, cmake generate fails.

To Reproduce Steps to reproduce the behavior:

  1. Open './cmake/StandardSettings.cmake'
  2. Scroll down to 'option(${PROJECT_NAME}_USE_GOOGLE_MOCK "Use the GoogleMock project for extending the unit tests." OFF)'
  3. Modify OFF -> ON (activate gmock)
  4. Try to generate cmake
  5. See error Target "tmp_test_Tests" links to target ""GTest::gmock" but the target was not found"
  6. See error Target "tmp_test_Tests" links to target ""GTest::gmock_main" but the target was not found"

Expected behavior Generation should work without any error

Screenshots image

Desktop (please complete the following information):

Additional context

radupaulstefan commented 2 years ago

Worked for me with this change: test/CMakeLists.txt line 49 set(GOOGLE_MOCK_LIBRARIES GTest::gmock GTest::gmock_main) -> set(GOOGLE_MOCK_LIBRARIES gmock)

If this is really a bug and not an issue with my environment (some missing or not installed correctly dependency) I can make a PR with a fix.

filipdutescu commented 2 years ago

Hello, thanks for reporting this bug! I am not sure it was not due to you not having GMock installed globally on your environment, in an accessible path, as that is the intended way it should be used. Have you tried using the dockerfile to see if in the container everything works as intended? If not, you might be right and there is a mistake made in the linking part.