googletest
googletest copied to clipboard
Add CMake aliases
GTest exports the following targets:
GTest::gtestGTest::gtest_mainGTest::gmockGTest::gmock_main
This targets should also be available when adding gtest with add_subdirectory (or FetchContent), because this should behave the same way as adding GTest with find_package. So somewhere, we should add the aliases to these targets, i.e.
add_library(GTest::gtest ALIAS gtest)
add_library(GTest::gtest_main ALIAS gtest_main)
add_library(GTest::gmock ALIAS gmock)
add_library(GTest::gmock_main ALIAS gmock_main)
I am not sure, where I should add these aliases.
Anything related to CMake is community supported. We do not use it internally and we are not in position to check. In general the maintainers would look for community consensus.
My 2 cents,
GTest namespace
First this CMake install NAMESPACE (GTest) is defined here:
https://github.com/google/googletest/blob/306f3754a71d6d1ac644681d3544d06744914228/googletest/CMakeLists.txt#L98
then used here:
https://github.com/google/googletest/blob/306f3754a71d6d1ac644681d3544d06744914228/googletest/CMakeLists.txt#L105
To use this variable ${cmake_package_name}, it should be defined somewhere else IMHO...
Edit: should be defined before including internal_utils.cmake: https://github.com/google/googletest/blob/306f3754a71d6d1ac644681d3544d06744914228/googletest/CMakeLists.txt#L90-L91
gtest and gtest_main targets
these libraries are defined later using a custom function cxx_library: https://github.com/google/googletest/blob/306f3754a71d6d1ac644681d3544d06744914228/googletest/CMakeLists.txt#L128-L129
which call cxx_library_with_type:
https://github.com/google/googletest/blob/306f3754a71d6d1ac644681d3544d06744914228/googletest/cmake/internal_utils.cmake#L197-L203
which call the add_library:
https://github.com/google/googletest/blob/306f3754a71d6d1ac644681d3544d06744914228/googletest/cmake/internal_utils.cmake#L147-L150
so we should try to add the add_library(... ALIAS ...) to this function IMHO
gmock and gmock_main targets
pretty the same story: https://github.com/google/googletest/blob/7b1cf6dd5fbe0c22c5e638fce8caf7f0f5c1abbf/googlemock/CMakeLists.txt#L89-L107
note gmock CMakeLists.txt include the gtest one https://github.com/google/googletest/blob/7b1cf6dd5fbe0c22c5e638fce8caf7f0f5c1abbf/googlemock/CMakeLists.txt#L51-L55
note: gmock install rules seems to use an other macro/function: https://github.com/google/googletest/blob/306f3754a71d6d1ac644681d3544d06744914228/googlemock/CMakeLists.txt#L121 defined here (EDIT: just adding targets to the googletest target): https://github.com/google/googletest/blob/306f3754a71d6d1ac644681d3544d06744914228/googletest/cmake/internal_utils.cmake#L327 (ed notice the of variable ${targets_export_name})
can i take this?
Do whatever you think is best.
On Mon, 7 Sep 2020, 17:57 Piotr Zarycki, [email protected] wrote:
can i take this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/googletest/issues/2429#issuecomment-688324891, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN5J4ZX3WG3U3OE7TXYD323SETNSHANCNFSM4IPGCP7A .
Is there any progress on this?
I think there is a pull request(https://github.com/google/googletest/pull/3155) for the same issue
@derekmauro or @gennadiycivil please close this (since #3155 is merged).
ps: I don't have right to this repo to close it myself...
hey, I would like to contribute to this issue. Please assign this to me.
I think the issue is resolved.