Repository navigation
Add CMake targets for base_game_framework and simple_renderer - #138
Merged
Merged
Conversation
agdktunnel's CMakeLists.txt listed the 44 source files of
BaseGameFramework and simple_renderer by relative path, along with their
include directories, so another game couldn't reuse them without copying
the lists. Each library now has its own CMakeLists.txt defining a static
library target with its include directories and dependencies:
- base_game_framework: includes include/ and src/ (public, since
simple_renderer and games use some headers in src/), finds the AGDK
prefab packages it uses (game-activity, games-controller,
games-frame-pacing) if the caller hasn't, and compiles in the volk and
VMA implementations.
- The volk and VulkanMemoryAllocator headers default to agdk/third_party.
BGF_VOLK_INCLUDE_DIR / BGF_VMA_INCLUDE_DIR override them (relative to
the top level source directory; empty means the default), with a clear
error if the headers are missing. They are system includes, so their
~900 warnings (e.g. -Wnullability-completeness in vk_mem_alloc.h)
don't break users' -Wall -Werror builds.
- Its link interface keeps GameActivity_onCreate and the
BaseGameFrameworkUtils.registerUtilObject JNI method (only called from
Java) in the game's shared library: as a static library, its objects
(and game-activity's) are only linked in when referenced, so a game
that didn't reference them yet lost both. agdktunnel's own
-u GameActivity_onCreate linker flag is now unnecessary.
- simple_renderer: links base_game_framework (adding it if the caller
hasn't); users include "simple_renderer/<header>.h".
- Both are C++17 without extensions (-std=c++17), position independent,
and take warning flags from the caller.
- An unused variable in RendererVk's constructor is removed (-Wall).
agdktunnel adds both with add_subdirectory and links them:
- The hardcoded -O0 is removed: it had no effect (debug builds get no
other -O flag, and release's -O2 came after it). -std=c++17 is now
CMAKE_CXX_STANDARD, and cmake_minimum_required is 3.18.1 (Gradle uses
CMake 3.22.1).
- Its own defines are set on its target instead of for every target, so
the libraries don't get them. glm's configuration (GLM_FORCE_*) is
public on the glm target, which the game and glm must agree on.
- It no longer finds or links games-controller and games-frame-pacing
itself (it doesn't use them; base_game_framework does), and an unused
variable is removed.
Tested:
- The compile commands for all 90 files, 4 ABIs, debug and release only
differ in the removed -O0, volk/VMA as system includes, include order
(no header name exists in more than one include directory), and the
library sources no longer getting agdktunnel's defines and include
paths (which they don't use). glm keeps its defines.
- libagdktunnel.so exports GameActivity_onCreate and the same JNI
functions (21). 4-5 functions nothing calls are no longer exported,
since unreferenced library code isn't linked in (e.g.
GameController::SetControllerLight).
- Minimal games using the libraries the documented way (NDK toolchain,
outside Gradle): with -Wall -Werror, debug and release build with no
warnings; a stub android_main still exports GameActivity_onCreate and
registerUtilObject; relative and empty include directory overrides
work, and a missing one fails with the error.
- On a Pixel 10 Pro, debug and release (non-debuggable, debug key signed)
builds launch on Vulkan, play, and background and resume without
errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
agdktunnel's CMakeLists.txt listed the 44 source files of BaseGameFramework and simple_renderer by relative path, along with their include directories, so another game couldn't reuse them without copying the lists. Each library now has its own CMakeLists.txt defining a static library target with its include directories and dependencies:
agdktunnel adds both with add_subdirectory and links them: