Skip to content
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

Provide ALIAS targets to unify usage #3125

Closed
friendlyanon opened this issue Nov 20, 2020 · 2 comments · Fixed by #3155
Closed

Provide ALIAS targets to unify usage #3125

friendlyanon opened this issue Nov 20, 2020 · 2 comments · Fixed by #3155

Comments

@friendlyanon
Copy link

friendlyanon commented Nov 20, 2020

If googletest is made part of the dependent's build tree (via FetchContent), then usage is different compared to using it from an install location (via find_package).

Ever since FetchContent has been introduced, the example has been using googletest. See here.

Usage differences in code:

# make googletest part of hte build tree
include(FetchContent)
FetchContent_Declare(googletest
        GIT_REPOSITORY https://github.com/google/googletest.git
        GIT_TAG master)
FetchContent_MakeAvailable(googletest)

# no ALIAS target, must use non-namespaced target instead
target_link_libraries(my_target PRIVATE gtest_main)

# ----

# use googletest from an install location
find_package(GTest REQUIRED CONFIG)

# the install(EXPORT) command namespaces the targets
target_link_libraries(my_target PRIVATE GTest::gtest_main)

I see from another issue (#3040 (comment)), that due to CMake 3.19 deprecating <2.8.12 there are also plans to set that as the minimum version and conveniently 2.8.12 is also the version that introduced the ALIAS form for add_library.

@asoffer
Copy link
Contributor

asoffer commented Nov 29, 2020

We use Bazel almost exclusively internally, so most of the GoogleTest team is relatively unfamiliar with CMake. This seems like a reasonable request, but not one we are likely to prioritize. Would you be willing to send a PR suggesting these changes? Thanks!

ZedThree added a commit to ZedThree/googletest that referenced this issue Dec 4, 2020
@AlexanderStein
Copy link

Isn't this the same issue as #2429?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants