Skip to content

Commit

Permalink
build: do not export valgrind with export()
Browse files Browse the repository at this point in the history
in Seastar, valgrind library is only used at the build time, and is
used internally for accessing its header files when buildings its
internal .cc files. so we don't expect to expose it via `export()`,
for exposing it in `SeastarTargets.cmake`.

but somehow when building Seastar as a static library, valgrind is
still exposed in Seastar's CMake configuration file. if a CMake
based project consume Seastar using its CMake configuration file,
it runs into following failure when CMake generates the building
system:

```
-- Configuring done (2.5s)
CMake Error at external/seastar/build/release/SeastarTargets.cmake:52 (set_target_properties):
  The link interface of target "Seastar::seastar" contains:

    Valgrind::valgrind

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  external/seastar/build/release/SeastarConfig.cmake:36 (include)
  CMakeLists.txt:6 (find_package)
```

fortunately, in CMake 3.26, `BUILD_LOCAL_INTERFACE` was introduced
this problem in specific, so that the linked library is not included
by `export()` anymore.

in this change, we include `Valgrind::valgrind` using this generator
expression if the CMake's version is greater or equal to 3.26, so that
`Valgrind` is not required for building Seastar applications.

as this generator expression is not available on CMake versions lower
than 3.26, and the minimal required CMake version for building Seastar
is 3.13, and Seastar does support static build. The issue is still not
fully addressed even with this change with older CMake and if Seastar
is built as a static library.

previously, 372a16a intended to address this. but somehow Valgrind
is still exposed by SeastarTargets.cmake.

Refs scylladb#2180
Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov authored and avikivity committed Apr 18, 2024
1 parent f57292c commit 21fbccc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,17 @@ target_link_libraries (seastar
rt::rt
ucontext::ucontext
yaml-cpp::yaml-cpp
"$<BUILD_INTERFACE:Valgrind::valgrind>"
Threads::Threads)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.26)
target_link_libraries (seastar
PRIVATE
"$<BUILD_LOCAL_INTERFACE:Valgrind::valgrind>")
else ()
target_link_libraries (seastar
PRIVATE
"$<BUILD_INTERFACE:Valgrind::valgrind>")
endif ()

if (Seastar_DPDK)
target_link_libraries (seastar
PRIVATE
Expand Down

0 comments on commit 21fbccc

Please sign in to comment.