Skip to content

Commit

Permalink
msvc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbopet committed Feb 28, 2025
1 parent b4b4b90 commit 8535d29
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ if(NOT ${GTEST_FOUND})
OVERRIDE_FIND_PACKAGE)
fetchcontent_makeavailable(GTest)
endif()
if(MSVC)
# ------------------------------------------------------------------------------
# gtest MSVC fix
# ------------------------------------------------------------------------------
# For some reason, googletest has include path issues when built with MSVC.
# Specifically, this seems like some incorrect assumptions about include paths
# inside the gmock project.
# We can fix this by injecting the include paths here.
function(fix_gtest_include TARGET)
target_include_directories(
${TARGET}
PUBLIC $<BUILD_INTERFACE:${gtest_SOURCE_DIR}>
$<BUILD_INTERFACE:${gtest_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${gtest_SOURCE_DIR}/googletest>
$<BUILD_INTERFACE:${gtest_SOURCE_DIR}/googletest/include>
$<INSTALL_INTERFACE:include/${TARGET}>)
endfunction()
set(gtest_erroneous_targets gmock gmock_main)
foreach(target ${gtest_erroneous_targets})
fix_gtest_include(${target})
endforeach()
endif()

set(PREVIOUS_BUILD_TESTING ${BUILD_TESTING})
set(BUILD_TESTING OFF)
Expand Down

0 comments on commit 8535d29

Please sign in to comment.