Skip to content

Add CMake targets for base_game_framework and simple_renderer - #138

Merged
natetrost merged 1 commit into
android:mainfrom
natetrost:main
Nov 24, 2026
Merged

natetrost merged 1 commit into
android:mainfrom
natetrost:main

Conversation

@natetrost

Copy link
Copy Markdown
Contributor

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/.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.

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.
@natetrost
natetrost merged commit e01c5cc into android:main Nov 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant