Ffilesystem for Android
May 26, 2026 · View on GitHub
Using CMake and the Android Native Development Kit (NDK), Ffilesystem can be built for Android from the command line. Android NDK supports multiple operating systems and is installed via Android Studio or Homebrew:
brew install android-ndk
CTest with Android NDK
Because Android binaries cannot run on the host, the standard
ctest (which executes the test binary at build time to
enumerate tests) does not work when cross-compiling. Three modes are
supported:
Mode 1 — Build only (default)
Tests are not built. Use this for quick compile/link validation:
cmake --workflow android
Mode 2 — Build and register tests, no runner
Tests are compiled and registered. ctest will show them as registered
but cannot run them without a device or emulator.
cmake --workflow android-tests
or explicitly:
cmake -B build-android --toolchain android.cmake \
-Dffilesystem_fortran=off \
-Dffilesystem_BUILD_TESTING=on
cmake --build build-android
ctest --test-dir build-android --show-only
Mode 3 — Build, discover, and run tests with a runner
If you have an Android emulator or device configured as a runner (e.g.
via CMAKE_CROSSCOMPILING_EMULATOR pointing to an adb shell wrapper) by preset.
Before using this script / tests, the Android SDK emulator must be running and connected via adb
e.g. "adb devices" should show a device.
Assuming Android SDK is installed on Linux or macOS, in a separate terminal:
- "source test/android.sh" from this directory
- list available emulators with "emulator -list-avds"
- start the emulator (e.g. "emulator -avd Medium_Phone_API_35")
- "adb devices" should show a device
- "cmake --workflow android-tests" to build tests for Android
cmake --workflow android-tests