Re: [OE-core][dunfell 16/18] cmake: FindGTest: Add target for gmock library

Eero Aaltonen
2021-12-13T13:02:46Z

On Fri, 2021-12-10 at 18:49 +0000, Jasper Orschulko wrote:
> Hello everyone,
>
> after some digging we identified the issue to be on our part.
> We have been using "GTEST_LIBRARY" and "GTEST_MAIN_LIBRARY" in our
> CMake scripts instead of "GTEST_LIBRARIES" and
> "GTEST_MAIN_LIBRARIES",
> as described in the cmake docs:
>
https://cmake.org/cmake/help/v3.16/module/FindGTest.html#result-variables

Thank you for providing more details.

The gmock target can be backported to dunfell in an alternative way, by
leaving out the
find_package(GTest QUIET NO_MODULE)

call and subsequent lines and letting the FindModule create all the
definitions. This would leave also the undocumented variables intact,
if that is desired.

This should be as simple as dropping the lines
----------------------------------------------
# first specifically look for the CMake version of GTest
find_package(GTest QUIET NO_MODULE)

# if we found the GTest cmake package then we are done, and
# can print what we found and return.
if(GTest_FOUND)
set(GTEST_FOUND ${GTest_FOUND})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTest HANDLE_COMPONENTS
CONFIG_MODE)

set(GTEST_LIBRARIES GTest::gtest)
set(GTEST_MAIN_LIBRARIES GTest::gtest_main)

__gtest_define_backwards_compatible_library_targets()

return()
endif()
----------------------------------------------

--
Eero Aaltonen