Skip to content

Commit

Permalink
Get include dirs from target rather than global variables.
Browse files Browse the repository at this point in the history
The global variable gtest_SOURCE_DIR is replaced by CMake when fetch-content is used with the name "GTest" and points to the root directory. The include directories from the gtest target are always valid.
  • Loading branch information
danfabo committed Feb 11, 2024
1 parent b75ecf1 commit f5448b3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions googlemock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ endif()
config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake

# Adds Google Mock's and Google Test's header directories to the search path.
# Get Google Test's include dirs from the target, gtest_SOURCE_DIR is broken
# when using fetch-content with the name "GTest".
get_target_property(gtest_include_dirs gtest INCLUDE_DIRECTORIES)
set(gmock_build_include_dirs
"${gmock_SOURCE_DIR}/include"
"${gmock_SOURCE_DIR}"
"${gtest_SOURCE_DIR}/include"
# This directory is needed to build directly from Google Test sources.
"${gtest_SOURCE_DIR}")
"${gtest_include_dirs}")
include_directories(${gmock_build_include_dirs})

########################################################################
Expand Down

0 comments on commit f5448b3

Please sign in to comment.