Skip to content

Commit 8feb21a

Browse files
committed
Updated README-cmake.md with build instructions for several platforms
1 parent 4294c06 commit 8feb21a

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

docs/INTRO-cmake.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,19 @@ target_link_libraries(hello PRIVATE SDL3::SDL3)
2727

2828
Build:
2929
```sh
30-
cmake .
31-
cmake --build .
30+
cmake -S . -B build
31+
cmake --build build
3232
```
3333

3434
Run:
35-
- On Windows the executable is in the Debug directory:
35+
- On Windows the executable is in the build Debug directory:
3636
```sh
37-
./Debug/hello
37+
cd build/Debug
38+
./hello
3839
```
39-
- On other platforms the executable is in the current directory:
40+
- On other platforms the executable is in the build directory:
4041
```sh
42+
cd build
4143
./hello
4244
```
4345

docs/README-cmake.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The CMake build system is supported on the following platforms:
66

77
* FreeBSD
88
* Linux
9-
* Microsoft Visual C
9+
* Microsoft Visual Studio
1010
* MinGW and Msys
1111
* macOS, iOS, tvOS, and visionOS with support for XCode
1212
* Android
@@ -20,42 +20,55 @@ The CMake build system is supported on the following platforms:
2020
* QNX 7.x/8.x
2121
* RiscOS
2222

23-
## Building SDL
23+
## Building SDL on Windows
2424

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

32-
Installation can be done using:
32+
## Building SDL on UNIX
33+
34+
SDL will build with very few dependencies, but for full functionality you should install the packages detailed in [README-linux.md](README-linux.md).
35+
36+
Assuming you're in the SDL source directory, building and installing to /usr/local can be done with:
3337
```sh
34-
cmake --install ~/build --prefix /usr/local # '--install' requires CMake 3.15, or newer
38+
cmake -S . -B build
39+
cmake --build build
40+
sudo cmake --install build --prefix /usr/local
3541
```
3642

37-
This will install SDL to /usr/local.
43+
## Building SDL on macOS
44+
45+
Assuming you're in the SDL source directory, building and installing to ~/SDL can be done with:
46+
```sh
47+
cmake -S . -B build -DSDL_FRAMEWORK=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
48+
cmake --build build
49+
cmake --install build --prefix ~/SDL
50+
```
3851

39-
### Building SDL tests
52+
## Building SDL tests
4053

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

47-
### Building SDL examples
60+
## Building SDL examples
4861

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

5568
## Including SDL in your project
5669

5770
SDL can be included in your project in 2 major ways:
58-
- using a system SDL library, provided by your (*nix) distribution or a package manager
71+
- using a system SDL library, provided by your (UNIX) distribution or a package manager
5972
- using a vendored SDL library: this is SDL copied or symlinked in a subfolder.
6073

6174
The following CMake script supports both, depending on the value of `MYGAME_VENDORED`.
@@ -181,7 +194,7 @@ Only shared frameworks are supported, no static ones.
181194

182195
#### Platforms
183196

184-
Use `-DCMAKE_PLATFORM_NAME=<value>` to configure the platform. CMake can target only one platform at a time.
197+
Use `-DCMAKE_SYSTEM_NAME=<value>` to configure the platform. CMake can target only one platform at a time.
185198

186199
| Apple platform | `CMAKE_SYSTEM_NAME` value |
187200
|-----------------|---------------------------|

0 commit comments

Comments
 (0)