Skip to content

Commit

Permalink
Cached definition of GTEST_* and GMOCK_* variables
Browse files Browse the repository at this point in the history
This fixes #1091, which introduced a shortcut defining GTEST_FOUND when all targets are defined.
However, those targets are defined by a previous source build of gtest and gmock as well.
Hence, if another catkin package is build below the same top-level project, the corresponding
GTEST_* variables were not defined anymore (because those values were not cached).

g
  • Loading branch information
rhaschke committed Jul 1, 2020
1 parent afb0e2a commit 57d0daa
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions cmake/test/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -376,24 +376,24 @@ if(FORCE_GTEST_GMOCK_FROM_SOURCE OR (NOT GMOCK_FOUND AND NOT GTEST_FOUND))
# set the same variables as find_package()
# do NOT set in the cache since when using gmock/gtest from source
# we must always add the subdirectory to have their targets defined
set(GMOCK_FOUND ${GMOCK_FROM_SOURCE_FOUND})
set(GMOCK_INCLUDE_DIRS ${GMOCK_FROM_SOURCE_INCLUDE_DIRS})
set(GMOCK_LIBRARY_DIRS ${GMOCK_FROM_SOURCE_LIBRARY_DIRS})
set(GMOCK_LIBRARIES ${GMOCK_FROM_SOURCE_LIBRARIES})
set(GMOCK_MAIN_LIBRARIES ${GMOCK_FROM_SOURCE_MAIN_LIBRARIES})
set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES})
set(GMOCK_FOUND ${GMOCK_FROM_SOURCE_FOUND} CACHE INTERNAL "")
set(GMOCK_INCLUDE_DIRS ${GMOCK_FROM_SOURCE_INCLUDE_DIRS} CACHE INTERNAL "")
set(GMOCK_LIBRARY_DIRS ${GMOCK_FROM_SOURCE_LIBRARY_DIRS} CACHE INTERNAL "")
set(GMOCK_LIBRARIES ${GMOCK_FROM_SOURCE_LIBRARIES} CACHE INTERNAL "")
set(GMOCK_MAIN_LIBRARIES ${GMOCK_FROM_SOURCE_MAIN_LIBRARIES} CACHE INTERNAL "")
set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES} CACHE INTERNAL "")
endif()

if(GTEST_FROM_SOURCE_FOUND)
# set the same variables as find_package()
# do NOT set in the cache since when using gtest from source
# we must always add the subdirectory to have their targets defined
set(GTEST_FOUND ${GTEST_FROM_SOURCE_FOUND})
set(GTEST_INCLUDE_DIRS ${GTEST_FROM_SOURCE_INCLUDE_DIRS})
set(GTEST_LIBRARY_DIRS ${GTEST_FROM_SOURCE_LIBRARY_DIRS})
set(GTEST_LIBRARIES ${GTEST_FROM_SOURCE_LIBRARIES})
set(GTEST_MAIN_LIBRARIES ${GTEST_FROM_SOURCE_MAIN_LIBRARIES})
set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
set(GTEST_FOUND ${GTEST_FROM_SOURCE_FOUND} CACHE INTERNAL "")
set(GTEST_INCLUDE_DIRS ${GTEST_FROM_SOURCE_INCLUDE_DIRS} CACHE INTERNAL "")
set(GTEST_LIBRARY_DIRS ${GTEST_FROM_SOURCE_LIBRARY_DIRS} CACHE INTERNAL "")
set(GTEST_LIBRARIES ${GTEST_FROM_SOURCE_LIBRARIES} CACHE INTERNAL "")
set(GTEST_MAIN_LIBRARIES ${GTEST_FROM_SOURCE_MAIN_LIBRARIES} CACHE INTERNAL "")
set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} CACHE INTERNAL "")
endif()
else()
if(GMOCK_FOUND)
Expand Down

0 comments on commit 57d0daa

Please sign in to comment.