Skip to content

Commit

Permalink
Updated README-cmake.md with build instructions for several platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 14, 2025
1 parent f731741 commit 51f1b95
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions docs/README-cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,50 @@ The CMake build system is supported on the following platforms:
* QNX 7.x/8.x
* RiscOS

## Building SDL
# Building SDL on Windows

Assuming the source tree of SDL is located at `~/sdl`,
this will configure and build SDL in the `~/build` directory:
Assuming you're in the SDL source directory, building and installing to C:/SDL can be done with:
```sh
cmake -S ~/sdl -B ~/build
cmake --build ~/build
cmake .
cmake --build . --config RelWithDebInfo
cmake --install . --config RelWithDebInfo --prefix C:/SDL
```

Installation can be done using:
# Building SDL on UNIX

SDL will build with very few dependencies, but for full functionality you should install the packages detailed in [README-linux.md](README-linux.md).

Assuming you're in the SDL source directory, building and installing to /usr/local can be done with:
```sh
cmake --install ~/build --prefix /usr/local # '--install' requires CMake 3.15, or newer
cmake .
cmake --build .
sudo cmake --install . --prefix /usr/local
```

This will install SDL to /usr/local.
# Building SDL on macOS

Assuming you're in the SDL source directory, building and installing to ~/SDL can be done with:
```sh
cmake . -DSDL_FRAMEWORK=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
cmake --build .
cmake --install . --prefix ~/SDL
```

### Building SDL tests

You can build the SDL test programs by adding `-DSDL_TESTS=ON` to the first cmake command above:
```sh
cmake -S ~/sdl -B ~/build -DSDL_TEST_LIBRARY=ON -DSDL_TESTS=ON
cmake . -DSDL_TESTS=ON
```
and then building normally. In this example, the test programs will be built and can be run from `~/build/tests/`.
and then building normally. The test programs will be built and can be run from `test/`.

### Building SDL examples

You can build the SDL example programs by adding `-DSDL_EXAMPLES=ON` to the first cmake command above:
```sh
cmake -S ~/sdl -B ~/build -DSDL_EXAMPLES=ON
cmake . -DSDL_EXAMPLES=ON
```
and then building normally. In this example, the example programs will be built and can be run from `~/build/examples/`.
and then building normally. The example programs will be built and can be run from `examples/`.

## Including SDL in your project

Expand Down

0 comments on commit 51f1b95

Please sign in to comment.