Update installation and usage instructions (fixes #136)

This commit is contained in:
Dmitry Marakasov 2022-06-16 14:56:50 +03:00
parent d50e7365da
commit 19a8d3b9f2

View File

@ -163,24 +163,30 @@ Following variables may be supplied to CMake to affect build:
To install the library system-wide, run: To install the library system-wide, run:
cmake . && make && make install ```sh
cmake .
cmake --build .
cmake --install .
```
You can change installation prefix with CMAKE_INSTALL_PREFIX cmake You can change installation prefix with CMAKE_INSTALL_PREFIX cmake
variable: variable:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local . && make && make install ```sh
cmake -DCMAKE_INSTALL_PREFIX=/usr/local .
cmake --build .
cmake --install .
```
SDL2pp installs pkg-config file, so it can be used with any build SDL2pp installs `pkg-config` file, so it can be used with any build
system that interacts with pkg-config, including CMake and GNU system that interacts with `pkg-config`, including CMake, meson and
Autotools. It also installs CMake module file, which can be used GNU Autotools. It also installs CMake module file, which can be used
from CMake directly: from CMake directly:
```cmake ```cmake
FIND_PACKAGE(SDL2PP REQUIRED) find_package(SDL2pp REQUIRED)
INCLUDE_DIRECTORIES(${SDL2PP_INCLUDE_DIRS}) target_link_libraries(mytarget SDL2pp::SDL2pp)
...
TARGET_LINK_LIBRARIES(... ${SDL2PP_LIBRARIES})
``` ```
## Bundling ## ## Bundling ##
@ -193,27 +199,23 @@ Just place the library into dedicated directory in your project
(for example, extlib/libSDL2pp) and add (for example, extlib/libSDL2pp) and add
```cmake ```cmake
SET(SDL2PP_WITH_IMAGE ON) # if you need SDL_image support set(SDL2PP_WITH_IMAGE ON) # if you need SDL_image support
SET(SDL2PP_WITH_MIXER ON) # if you need SDL_mixer support set(SDL2PP_WITH_MIXER ON) # if you need SDL_mixer support
SET(SDL2PP_WITH_TTF ON) # if you need SDL_ttf support set(SDL2PP_WITH_TTF ON) # if you need SDL_ttf support
ADD_SUBDIRECTORY(extlib/libSDL2pp) add_subdirectory(extlib/libSDL2pp)
``` ```
into your core CMakeLists.txt. This will act similar to how into your core CMakeLists.txt. This will act similar to how
FIND_PACKAGE usually does, and will provide ${SDL2PP_INCLUDE_DIRS} `find_package` usually does, and will provide `SDL2pp::SDL2pp`
and ${SDL2PP_LIBRARIES} variables for your project. You will then target for your project. You will then be able it as usual:
be able to use them as usual:
```cmake ```cmake
INCLUDE_DIRECTORIES(${SDL2PP_INCLUDE_DIRS}) target_link_libraries(mytarget SDL2pp::SDL2pp)
ADD_EXECUTABLE(mytarget ...)
TARGET_LINK_LIBRARIES(mytarget ${SDL2PP_LIBRARIES})
``` ```
If bundled, libSDL2pp does not build examples and becomes a static If bundled, libSDL2pp does not build examples and becomes a static
library, providing required SDL2 includes/libs in the mentioned library. See [hoverboard](https://github.com/AMDmi3/hoverboard-sdl/blob/master/CMakeLists.txt#L34-L40)
variables. project as an example of using both bundled and systemwide SDL2pp.
## Completeness ## Completeness