[Bug]: TESTONLY targets don't appear to get installed
- Linguagem predominante
- C++
- Estrelas
- 18.1k
- Forks
- 3.2k
- Merge médio
- 20h 36min
- PRs com merge (30d)
- 1
Descrição
### 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.
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.