Describe the issue
I'm trying to build and install Abseil with CMake and use a PUBLIC target that's marked TESTONLY.
|
absl_cc_library( |
|
NAME |
|
scoped_mock_log |
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:
$ 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
$ 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
d6ea4df 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
|
# TESTONLY: When added, this target will only be built if both |
|
# BUILD_TESTING=ON and ABSL_BUILD_TESTING=ON. |
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.
Describe the issue
I'm trying to build and install Abseil with CMake and use a
PUBLICtarget that's markedTESTONLY.abseil-cpp/absl/log/CMakeLists.txt
Lines 618 to 620 in c3b5022
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:
Then I look for a
absl::scoped_mock_logCMake targetYou can grep that file for a target like,
absl::optionalto see that it does exist.What version of Abseil are you using?
$ git show-ref HEAD
d6ea4df 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
abseil-cpp/CMake/AbseilHelpers.cmake
Lines 49 to 50 in d6ea4df
I think I'm required to add
ABSL_BUILD_TESTING=ONandBUILD_TESTING=ON(the default) in order to getTESTONLYtargets 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.