From fcd5e2608974d282dc8492facad3026273c1aded Mon Sep 17 00:00:00 2001 From: uditDewan Date: Sat, 18 Jul 2026 14:59:31 -0400 Subject: [PATCH] Fix exported include paths for absolute CMAKE_INSTALL_INCLUDEDIR The INSTALL_INTERFACE include directory was written as $/${CMAKE_INSTALL_INCLUDEDIR}, which unconditionally prepends the install prefix. When CMAKE_INSTALL_INCLUDEDIR is an absolute path, the exported GTestTargets.cmake ends up with an invalid doubled path such as "/usr/local//usr/local/include", and find_package consumers fail at configure time with "Imported target includes non-existent path". Relative paths inside $ are already interpreted relative to the installation prefix, so the explicit $/ prefix is redundant for relative values and wrong for absolute ones. Dropping it keeps the exported path identical for relative values (${_IMPORT_PREFIX}/include) and uses absolute values as-is. Fixes #4817 --- googlemock/CMakeLists.txt | 4 ++-- googletest/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt index 99b2411f3..33ec96363 100644 --- a/googlemock/CMakeLists.txt +++ b/googlemock/CMakeLists.txt @@ -105,10 +105,10 @@ endif() string(REPLACE ";" "$" dirs "${gmock_build_include_dirs}") target_include_directories(gmock SYSTEM INTERFACE "$" - "$/${CMAKE_INSTALL_INCLUDEDIR}>") + "$") target_include_directories(gmock_main SYSTEM INTERFACE "$" - "$/${CMAKE_INSTALL_INCLUDEDIR}>") + "$") ######################################################################## # diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index 2e5388945..64c0510cb 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -140,10 +140,10 @@ set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION}) string(REPLACE ";" "$" dirs "${gtest_build_include_dirs}") target_include_directories(gtest SYSTEM INTERFACE "$" - "$/${CMAKE_INSTALL_INCLUDEDIR}>") + "$") target_include_directories(gtest_main SYSTEM INTERFACE "$" - "$/${CMAKE_INSTALL_INCLUDEDIR}>") + "$") if(CMAKE_SYSTEM_NAME MATCHES "QNX" AND CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 7.1) target_link_libraries(gtest PUBLIC regex) endif()