This Magisk module contains CMake binaries and the ninja binary for arm64 CPUs


ASUS_I006D:/data/local/tmp/develop $ ASUS_I006D:/ $ cmake --version
cmake version 4.4.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
ASUS_I006D:/ $ 

ASUS_I006D:/ $ ninja --version
1.13.2
ASUS_I006D:/ $ 


The binaries are dynamically linked for the Android OS libraries only:

ASUS_I006D:/ $ myldd cmake

# Executing ldd "/system/bin/cmake" 
	linux-vdso.so.1 => [vdso] (0x7882357000)
	libdl.so => /apex/com.android.runtime/lib64/bionic/libdl.so (0x787ee48000)
	libm.so => /apex/com.android.runtime/lib64/bionic/libm.so (0x787e045000)
	libc.so => /apex/com.android.runtime/lib64/bionic/libc.so (0x787e0b1000)
ASUS_I006D:/ $ 

ASUS_I006D:/ $ myldd ninja 

# Executing ldd "/system/bin/ninja" 
	linux-vdso.so.1 => [vdso] (0x7ef5f28000)
	libm.so => /apex/com.android.runtime/lib64/bionic/libm.so (0x7ef0c40000)
	libdl.so => /apex/com.android.runtime/lib64/bionic/libdl.so (0x7ef0ca1000)
	libc.so => /apex/com.android.runtime/lib64/bionic/libc.so (0x7ef0cc0000)
ASUS_I006D:/ $ 



The Magisk Module contains two api-level.h files - one for the clang (this is the api-level.h file from the Android NDK r27d):

/system/usr/include/android/api-level-for-clang.h

and one for the gcc:

/system/usr/include/android/api-level-for-gcc.h

cmake selects the api-level.h file depending on the name of the used toolchain file.


To use a different api-level.h file, set the environment variable PREFIX to the sysroot directory with the api-level.h file  before starting cmake, e.g:

PREFIX=/data/local/tmp/develop/sysroot/usr  cmake ..        


The code to select the api-level.h file is in the file

/system/usr/share/cmake-4.4/Modules/CMakeDetermineSystem.cmake


The code is:

        if(DEFINED ENV{PREFIX})
          set( $ENV{PREFIX}/include/android/api-level.h)
        else()
          message(STATUS " The toolchain used is (CMAKE_TOOLCHAIN_FILE) = ${CMAKE_TOOLCHAIN_FILE}" )

          if(CMAKE_TOOLCHAIN_FILE MATCHES "android\\-gcc")
            message(STATUS " Using the api-level.h file for GCC")
            set(_ANDROID_API_LEVEL_H /system/usr/include/android/api-level-for-gcc.h)
          else()
            message(STATUS "Using the api-level.h file for clang")
            set(_ANDROID_API_LEVEL_H /system/usr/include/android/api-level-for-clang.h)
          endif()

           message(STATUS "The used api-level.h file is ${_ANDROID_API_LEVEL_H}" )
        endif() 

-> cmake selects the api-level.h file for the gcc if the toolchain file used matches the regular expression "*android-gcc*" , For all other toolchain files the api-level.h file for the clang is used.


Set the cmake variable CMAKE_TOOLCHAIN_FILE to define the toolchain file to use.

Example:

cmake -DCMAKE_TOOLCHAIN_FILE=/system/lib/android-gcc-cross/usr/local/share/android-gcc-cross/cmake/aarch64-unknown-linux-android31.cmake ..
    


History

07.08.2026 v4.4.2-v1.0.0
  initial release 

08.10.2026 v4.4.2-v1.1.0
  added an api-level.h file for the gcc toolchain 
  added code to select the api-level.h file depending on the name of the used CMake toolchain file
  updated ninja to version 1.13.2

