File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,29 @@ if(NOT ${GTEST_FOUND})
3030 GIT_TAG v1.14.0
3131 OVERRIDE_FIND_PACKAGE )
3232 fetchcontent_makeavailable (GTest)
33+
34+ if (MSVC )
35+ # ------------------------------------------------------------------------------
36+ # gtest MSVC fix
37+ # ------------------------------------------------------------------------------
38+ # For some reason, googletest has include path issues when built with MSVC.
39+ # Specifically, this seems like some incorrect assumptions about include paths
40+ # inside the gmock project.
41+ # We can fix this by injecting the include paths here.
42+ function (fix_gtest_include TARGET )
43+ target_include_directories (
44+ ${TARGET}
45+ PUBLIC $<BUILD_INTERFACE :${gtest_SOURCE_DIR} >
46+ $<BUILD_INTERFACE :${gtest_SOURCE_DIR} /include >
47+ $<BUILD_INTERFACE :${gtest_SOURCE_DIR} /googletest >
48+ $<BUILD_INTERFACE :${gtest_SOURCE_DIR} /googletest /include >
49+ $<INSTALL_INTERFACE :include /${TARGET} >)
50+ endfunction ()
51+ set (gtest_erroneous_targets gmock gmock_main)
52+ foreach (target ${gtest_erroneous_targets} )
53+ fix_gtest_include (${target} )
54+ endforeach ()
55+ endif ()
3356endif ()
3457
3558set (PREVIOUS_BUILD_TESTING ${BUILD_TESTING} )
You can’t perform that action at this time.
0 commit comments