← All tasks
cppgoogle/googletest #3125Not a task: already works

Provide ALIAS targets to unify usage

envgap__google__googletest-3125

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
93748a946684defd1494d5585dbc912e451e83f8
Manifest
googletest/CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

google/googletest #3125 · read the original issue
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](https://cmake.org/cmake/help/v3.11/module/FetchContent.html).



Usage differences in code:

```cmake

# 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 (https://github.com/google/googletest/issues/3040#issuecomment-717300633), 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`.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]