cmake: SDL3-shared target will always be a shared target

This commit is contained in:
Anonymous Maarten
2023-02-16 23:30:20 +01:00
committed by Anonymous Maarten
parent 6ae1578691
commit dc138ee3d4
6 changed files with 83 additions and 70 deletions

View File

@@ -2,13 +2,6 @@
(www.cmake.org)
SDL's build system was traditionally based on autotools. Over time, this
approach has suffered from several issues across the different supported
platforms.
To solve these problems, a new build system based on CMake was introduced.
It is developed in parallel to the legacy autotools build system, so users
can experiment with it without complication.
The CMake build system is supported on the following platforms:
* FreeBSD
@@ -19,26 +12,27 @@ The CMake build system is supported on the following platforms:
* Android
* Emscripten
* RiscOS
* Playstation 2
* Playstation Vita
* Nintendo 3DS
## Building SDL
Assuming the source for SDL is located at `~/sdl`
Assuming the source for SDL is located at `~/sdl`.
```sh
cd ~
mkdir build
cd build
cmake ~/sdl
cmake --build .
cmake -S ~/sdl -B ~/build
cmake --build ~/build
```
This will build the static and dynamic versions of SDL in the `~/build` directory.
This will build SDL in the `~/build` directory.
Installation can be done using:
```sh
cmake --install . # '--install' requires CMake 3.15, or newer
cmake --install ~/build --prefix /usr/local # '--install' requires CMake 3.15, or newer
```
This will install SDL to /usr/local.
## Including SDL in your project
SDL can be included in your project in 2 major ways:
@@ -74,11 +68,13 @@ For CMake to find SDL, it must be installed in [a default location CMake is look
The following components are available, to be used as an argument of `find_package`.
| Component name | Description |
|----------------|--------------------------------------------------------------------------------------------|
| SDL3 | The SDL3 shared library, available through the `SDL3::SDL3` target [^SDL_TARGET_EXCEPTION] |
| SDL3-static | The SDL3 static library, available through the `SDL3::SDL3-static` target |
| SDL3_test | The SDL3_test static library, available through the `SDL3::SDL3_test` target |
| Component name | Description |
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| SDL3-shared | The SDL3 shared library, available through the `SDL3::SDL3-shared` target |
| SDL3-static | The SDL3 static library, available through the `SDL3::SDL3-static` target |
| SDL3_test | The SDL3_test static library, available through the `SDL3::SDL3_test` target |
| SDL3 | The SDL3 library, available through the `SDL3::SDL3` target. This is an alias of `SDL3::SDL3` or `SDL3::SDL3-static`. This component is always available. |
| Headers | The SDL3 headers, available through the `SDL3::Headers` target. This component is always available. |
### Using a vendored SDL
@@ -150,5 +146,3 @@ To use, set the following CMake variables when running CMake's configuration sta
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_ARCHITECTURES=arm64`
```
[^SDL_TARGET_EXCEPTION]: `SDL3::SDL3` can be an ALIAS to a static `SDL3::SDL3-static` target for multiple reasons.