-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix gtest-not-found bug #1040
Merged
Merged
Fix gtest-not-found bug #1040
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,8 +212,9 @@ endfunction() | |
# Google recommends distributing GTest and GMock as source only, to be built with the same | ||
# flags as that which is being tested. | ||
# | ||
# :param[in] include_path: Path to search for Google Test includes | ||
# :param[in] src_path: Path to search for Google Test sources | ||
# :param[in] gtest_path: Base path to search for gtest sources and includes, eg /usr | ||
# :param[in] googletest_path: Base path to search for googletest-packaged gtest/gmock, | ||
# eg, /usr/src/googletest | ||
# :param[out] gtest_found: Whether or not GTest was found in the paths provided | ||
# :param[out] gtest_include_dir: The include path to access GTest's headers | ||
# :param[out] gtest_lib_dir: The library path to access GTest's libraries | ||
|
@@ -226,16 +227,19 @@ endfunction() | |
# :param[out] gmock_main_libs: GMock's main libraries | ||
# :param[out] base_dir: The base directory containing Google Test and/or GMock CMakeLists.txt | ||
# | ||
function(catkin_find_google_test_source include_path src_path | ||
function(catkin_find_google_test_source gtest_path googletest_path | ||
gtest_found gtest_include_dir gtest_lib_dir gtest_libs gtest_main_libs | ||
gmock_found gmock_include_dir gmock_lib_dir gmock_libs gmock_main_libs | ||
base_dir | ||
) | ||
#Find GTest | ||
set(_gtest_include_paths "${include_path}/gtest") | ||
set(_gtest_source_paths "${src_path}/gtest/src") | ||
list(APPEND _gtest_include_paths "${include_path}/googletest/googletest/include/gtest") | ||
list(APPEND _gtest_source_paths "${src_path}/googletest/googletest/src") | ||
# Path to gtest from the libgtest-dev Debian package. | ||
set(_gtest_include_paths "${gtest_path}/include/gtest") | ||
set(_gtest_source_paths "${gtest_path}/src/gtest/src") | ||
|
||
# Path to gtest from the googletest Debian package. | ||
list(APPEND _gtest_include_paths "${googletest_path}/googletest/include/gtest") | ||
list(APPEND _gtest_source_paths "${googletest_path}/googletest/googletest/src") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The double "googletest" seems to be a mistake. The |
||
|
||
if(CATKIN_TOPLEVEL) | ||
# Ensure current workspace is searched before system path | ||
list(INSERT _gtest_include_paths 0 "${CMAKE_SOURCE_DIR}/googletest/googletest/include/gtest") | ||
|
@@ -254,11 +258,14 @@ function(catkin_find_google_test_source include_path src_path | |
set(${gtest_main_libs} ${_gtest_main_libs} PARENT_SCOPE) | ||
set(${base_dir} ${_gtest_base_dir} PARENT_SCOPE) | ||
|
||
#Find GMock | ||
set(_gmock_include_paths "${include_path}/gmock") | ||
set(_gmock_source_paths "${src_path}/gmock/src") | ||
list(APPEND _gmock_include_paths "${include_path}/googletest/googlemock/include/gmock") | ||
list(APPEND _gmock_source_paths "${src_path}/googletest/googlemock/src") | ||
# Path to gmock from the google-mock Debian package before v1.8.0. | ||
set(_gmock_include_paths "${gtest_path}/include/gmock") | ||
set(_gmock_source_paths "${gtest_path}/src/gmock/src") | ||
|
||
# Path to gmock from the googletest Debian package. | ||
list(APPEND _gmock_include_paths "${googletest_path}/googlemock/include/gmock") | ||
list(APPEND _gmock_source_paths "${googletest_path}/googlemock/src") | ||
|
||
if(CATKIN_TOPLEVEL) | ||
# Ensure current workspace is searched before system path | ||
list(INSERT _gmock_include_paths 0 "${CMAKE_SOURCE_DIR}/googletest/googlemock/include/gmock") | ||
|
@@ -281,9 +288,9 @@ function(catkin_find_google_test_source include_path src_path | |
set(${base_dir} ${_gmock_base_dir} PARENT_SCOPE) | ||
endif() | ||
|
||
#In googletest 1.8, gmock and gtest where merged inside googletest | ||
#In this case, including gmock builds gmock twice, so instead we need to include googletest | ||
#which will include gtest and gmock once | ||
# In googletest 1.8, gmock and gtest were merged inside googletest | ||
# In this case, including gmock builds gmock twice, so instead we need to include googletest | ||
# which will include gtest and gmock once | ||
if(_gtest_found) | ||
get_filename_component(_gtest_base_dir_realpath ${_gtest_base_dir} REALPATH) | ||
get_filename_component(_global_base_dir ${_gtest_base_dir_realpath} PATH) | ||
|
@@ -299,11 +306,13 @@ if(NOT GMOCK_FOUND OR NOT GTEST_FOUND) | |
# If we find one but not the other, see if we can get both from source | ||
# only add gmock/gtest directory once per workspace | ||
if(NOT TARGET gtest AND NOT TARGET gmock) | ||
# Fall back to system-installed gmock source (e.g. Ubuntu) | ||
set(_include_paths "/usr/include" "/usr/src") | ||
set(_source_paths "/usr/src") | ||
# Path to base of legacy libgtest-dev and google-mock packages. | ||
set(_gtest_path "/usr") | ||
|
||
# Path to base of new googletest package, which includes both gtest and gmock. | ||
set(_googletest_path "/usr/src/googletest") | ||
|
||
catkin_find_google_test_source("${_include_paths}" "${_source_paths}" gtest_found | ||
catkin_find_google_test_source("${_gtest_path}" "${_googletest_path}" gtest_found | ||
gtest_include_dir gtest_lib_dir gtest_libs gtest_main_libs | ||
gmock_found gmock_include_dir gmock_lib_dir gmock_libs | ||
gmock_main_libs base_dir) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously this is changing the signature of the function, but I'm pretty sure the only place that's calling it is in this file; it's not really an external interface, so it should be safe to change.