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-ndkBecause Android binaries cannot run on the host, the standard
gtest_discover_tests (which executes the test binary at build time to
enumerate tests) does not work when cross-compiling. Three modes are
supported:
Tests are not built. Use this for quick compile/link validation:
cmake --workflow androidTests are compiled and registered using gtest_add_tests (source
parsing only — no host execution). ctest will show them as registered
but cannot run them without a device or emulator.
cmake --workflow android-testsor 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-onlyIf 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 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