Support non-Ubuntu-package version of gmock and gtest
envgap__cartographer-project__cartographer-73
01 / FAILURE SIGNATURE
As reported upstream
No identifying execution failure has been captured.
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
404bbfcc2bf48fe1a5e85d0b20d6119032fe204a- Manifest
CMakeLists.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
cartographer-project/cartographer #73 · read the original issue
cmake/functions.cmake depends on Ubuntu package version of gmock and gtest install.
```
macro(google_enable_testing)
set(GMOCK_SRC_DIR "/usr/src/gmock" CACHE STRING "Path to google-mock sources.")
add_subdirectory(${GMOCK_SRC_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
```
For example in Fedora 24, /usr/src/gmock does not contains CMakeLists.txt.
Latest (1.8+) version of googletest (containing gmock) supports system wide install again.
So, add_subdirectory for gmock will be no longer required in latest gtest environment.
(I have just commented out these lines for my build.)
Also, in environments with a built-from-source version of gmock, libgmock_main requires linking pthread.
I have simply modified macro(_common_test_stuff) as following:
```
diff --git a/cmake/functions.cmake b/cmake/functions.cmake
index 27f0beb..031412e 100644
--- a/cmake/functions.cmake
+++ b/cmake/functions.cmake
@@ -221,7 +221,7 @@ macro(_common_test_stuff)
# Make sure that gmock always includes the correct gtest/gtest.h.
target_include_directories("${NAME}" SYSTEM PRIVATE
"${GMOCK_SRC_DIR}/gtest/include")
- target_link_libraries("${NAME}" gmock_main)
+ target_link_libraries("${NAME}" gmock_main pthread)
endmacro()
function(google_catkin_test NAME)
```
(This hard-code should be replaced using find_package.)
Currently, I could not make a PR about this since I have not understood the structure of Google-style CMake.
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]