添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Incorrect gtest include directories when building gmock added with FetchContent on Windows

I added googletest to a project as described it the instructions ( googletest/quickstart-cmake ). It works on Ubuntu and MacOS, however on Windows I have errors when build the project, like gmock-port.h(56): fatal error C1083: Cannot open include file: 'gtest/internal/gtest-port.h': No such file or directory .

This happens, because gmock project is generated with paths to googletest root directory instead of gtest:

 -ID:\a\lldb-mi\lldb-mi\build\_deps\gtest-src\googlemock\include
 -ID:\a\lldb-mi\lldb-mi\build\_deps\gtest-src\googlemock
 -ID:\a\lldb-mi\lldb-mi\build\_deps\gtest-src\include
 -ID:\a\lldb-mi\lldb-mi\build\_deps\gtest-src

whereas gtest project has correct paths:

 -ID:\a\lldb-mi\lldb-mi\build\_deps\gtest-src\googletest\include
 -ID:\a\lldb-mi\lldb-mi\build\_deps\gtest-src\googletest

googlemock adds required directory as '${gtest_SOURCE_DIR}/include' ( this line ). I checked gtest_SOURCE_DIR in the CMakeCache and it is correct: gtest_SOURCE_DIR:STATIC=\a\lldb-mi\lldb-mi\build\_deps\gtest-src\googletest .

Also, I can successfully build googletest+googlemock on Windows outside my project.

Generators: Visual Studio 16, Ninja.

Compiler: cl.exe.

CMake version: 3.19.20122902-MSVC_2.

Edited by Tatyana Krasnukha