After you've downloaded the library onto your machine and have checked it into your source control system, make the following changes to your project's build settings.
Static library
Do the following steps to link your project to the static library:
- Add
gamesdk/include
to your compiler include paths. - Include
swappy/swappyVk.h
for integration with Vulkan. In most cases, the header file contains all the functions you need to integrate the library into your engine. -
Add a path of the following form in your linker library paths:
gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release
For example:
gamesdk/libs/arm64-v8a_API24_NDK17_cpp_static_Release
Add
-lswappy_static
to your linker command.
Shared library
The above steps statically link against a version of the Frame Pacing library compiled for the given ABI, API level, NDK and STL combination. If the combination is not available for your settings, you can instead link against the shared library:
- Follow steps 1 and 2 from the previous section to update your compiler include paths and use the appropriate header file.
Add a path of the following form in your linker library paths:
gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release/lib/swappy
Add
-lswappy
to your linker command.
Static linking will give you a much smaller code footprint as you don’t need to
bundle the libswappy.so
shared library.
Using CMake (static library only)
If you are using CMake, see the gamesdk/samples/bouncyball/app/CMakeLists.txt
file in the downloaded library
for an example CMake configuration. It includes a utility file, gamesdk/samples/gamesdk.cmake
,
that performs final checks, adds the proper compiler include paths, and
generates a target that you can use to link the library.
To use this utility, do the following:
- Include this file in your CMakeLists.txt:
include("path/to/gamesdk/samples/gamesdk.cmake")
- Call the
add_gamesdk_target
function with the folder containing the gamesdk:add_gamesdk_target(PACKAGE_DIR path/to/gamesdk)
- In your
target_link_libraries
for your native library, addswappy
as a dependency:target_link_libraries(native-lib swappy ...)
For advanced usage of CMake, see the gamesdk.cmake
source file.