abseil / abseil/abseil-cpp

[Bug]: TESTONLY targets don't appear to get installed

Đang mở
#1,407 9 bình luận 0 reaction 1 người được giao Được @derekmauro nhận Xem trên GitHub
Ngôn ngữ chính
C++
Star
18.1k
Fork
3.2k
Merge trung bình
20 giờ 36 phút
Pull request đã merge (30 ngày)
1

Mô tả

### Describe the issue

I'm trying to build and install Abseil with CMake and use a `PUBLIC` target that's marked `TESTONLY`.

https://github.com/abseil/abseil-cpp/blob/c3b5022604551a045e383c68071d7be0a807839d/absl/log/CMakeLists.txt#L618-L620

After building and installing, I do not see a cmake target named `absl::scoped_mock_log`.

### Steps to reproduce the problem

I fetch build and install abseil in a temporary location as follows:

```console
$ git clone https://github.com/abseil/abseil-cpp
$ cd abseil-cpp
$ cmake -S. -Bcmake-out -DCMAKE_BUILD_TYPE=Release -GNinja -DCMAKE_CXX_STANDARD=14 -DABSL_BUILD_TESTING=ON -DABSL_USE_GOOGLETEST_HEAD=ON
$ cmake --build cmake-out
$ cmake --install cmake-out --prefix /tmp/absl
```

Then I look for a `absl::scoped_mock_log` CMake target

```console
$ find /tmp/absl/ -name '*.cmake'
/tmp/absl//lib/cmake/absl/abslTargets.cmake
/tmp/absl//lib/cmake/absl/abslConfig.cmake
/tmp/absl//lib/cmake/absl/abslTargets-release.cmake
$ grep absl::scoped_mock /tmp/absl//lib/cmake/absl/abslTargets.cmake
$
```
You can grep that file for a target like, `absl::optional` to see that it _does_ exist.

### What version of Abseil are you using?

$ git show-ref HEAD
d6ea4df62db59dc1ebc1fd3b62146700640ef400 refs/remotes/origin/HEAD

### What operating system and version are you using?

macOS 13.2.1

### What compiler and version are you using?

$ cc --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

### What build system are you using?

$ cmake --version
cmake version 3.25.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

### Additional context

From looking at the this file

https://github.com/abseil/abseil-cpp/blob/d6ea4df62db59dc1ebc1fd3b62146700640ef400/CMake/AbseilHelpers.cmake#L49-L50

I think I'm required to add `ABSL_BUILD_TESTING=ON` and `BUILD_TESTING=ON` (the default) in order to get `TESTONLY` targets to work.

I think this is probably a misfeature. I think every target that is considered a public API point that users may want to use should be built and installed by default, even without explicitly enabling testing.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.