Define GMOCK_* and GTEST_* variables in a new subproject
@@ -314,6 +314,24 @@ find_package(GMock QUIET)
if(TARGET gtest AND TARGET gtest_main AND TARGET gmock AND TARGET gmock_main)
set(GMOCK_FOUND TRUE)
set(GTEST_FOUND TRUE)
+
+ # If we build these from source in a previous catkin (sub)project,
+ # define all variables from their FROM_SOURCE counterparts (again).
+ # As these variables are (explicitly!) not cached, they become reset on a new project.
+ if(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})
+ endif()
+ if(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})
+ endif()
else()
find_package(GTest QUIET)
endif()
