abseil / abseil/abseil-cpp

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

未關閉
#1,407 9 則留言 0 個 reaction 已指派 1 人 已被 @derekmauro 認領 在 GitHub 檢視
主要語言
C++
星號
18.1k
分支
3.2k
平均合併
20 小時 36 分鐘
30 天內合併 PR
1

描述

### 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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。