-
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
Define GMOCK_* and GTEST_* variables in a new subproject #1101
Conversation
I see. Please suggest an alternative solution then to fix the broken state. |
Maybe, alternatively, we could repeat the code setting those variables where GMOCK_FOUND and GTEST_FOUND are originally defined in the offending situation: Lines 313 to 317 in 4fe89dd
To be on the really safe side, you might want to test the variables |
Unfortunately I don't have a proposal at hand. This CMake logic is extremely fragile and I wouldn't consider a "cmake project that comprises multiple catkin sub-projects" to be a supported use case - at least this is not used / tested anywhere. So I am not surprised recent changes broke that use case. I am happy to review / consider any kind of patch if it looks reasonably safe.
I would wonder if this would only cover some of the cases (depending on where/how Googletest is found) but not correctly define the variable in other cases when including multiple catkin packages within a single CMake context. Please consider updating the pull request as you imagine it. Even if it doesn't solve all cases but improves the one you are mostly interested in that would be fine with me to merge. |
57d0daa
to
350e429
Compare
@dirk-thomas, I pushed the suggested alternative solution. |
The patch looks fine to me. If it works for your use case 👍 from me. Please target the default branch though which is |
Maybe also update the title to reflect the changed patch. |
350e429
to
9ff9b36
Compare
Rebased onto noetic-devel and rephrased PR title. Thanks for back-porting to Melodic! |
Thanks for the patch. |
Cherry-picked to |
This fixes the following bug occurring for a cmake project that comprises multiple catkin sub-projects:
I think this issue was introduced in #1091 (definitely after release 0.7.24) when a shortcut defining
GTEST_FOUND
was introduced as soon as allgtest
andgmock
targets are defined:catkin/cmake/test/gtest.cmake
Lines 312 to 317 in 4fe89dd
However, those targets might have been defined via a previous source build of gtest and gmock.
In this case, when entering the second catkin sub-package, all GTEST_* variables are undefined again, but the targets still exist causing GTEST_FOUND to be defined w/o defining the remaining variables.
This PR fixes this by defining both GTEST_* and GMOCK_* variables in a cached fashion in this case.