Skip to content

Commit

Permalink
build: enable Seastar to build shared and static libs in a single build
Browse files Browse the repository at this point in the history
before this change, we respect the CMake variable named
`BUILD_SHARED_LIBS`, and build shared libraries if it is set, build
static libraries otherwise. but this model cannot fulfill the needs
of a parent project which needs to build both static and shared
seastar libraries with different configuration in a multi-config
generator settings. as `BUILD_SHARED_LIBS` is a CMake variable which
cannot be changed at build time, and hence cannot be assigned with
different values using generator expression.

so, in this change, we add two options

- Seastar_BUILD_STATIC_LIBS
- Seastar_BUILD_SHARED_LIBS

to configure if the build should generated static libraries and
shared libraries respectively. but `BUILD_SHARED_LIBS` is still
supported, and the behavior is backward compatible. the only
user-visible differences are, the libraries of

- seastar
- seastar_testing
- seastar_perf_testing

are now aliases of the targets which builds the static or shared
libraries. so one cannot build "seastar" as a target anymore,
but should specify which library to build:

```
$ cmake --build build --target seastar # does not work anymore
$ cmake --build build --target seastar-static
$ cmake --build build --target seastar-shared
```

the reason is the limit of an ALIAS library, which cannot be used
as a target. but we still need to use a non-interface library
to generate .pc file, where, for instance, we use
`$<TARGET_FILE_NAME:seastar_testing>` for the library list of a
certain Seastar library.

but a CMake-based project including seastar can still link against
it using "seastar" as a library.

Refs scylladb/scylladb#2717
Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Sep 17, 2024
1 parent 69f88e2 commit da15e0c
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 61 deletions.
Loading

0 comments on commit da15e0c

Please sign in to comment.