Toolchain-android.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Cross-compiling requires CMake 2.6 or newer. Example:
  2. # cmake .. -DCMAKE_TOOLCHAIN_FILE=../XCompile-Android.txt -DHOST=arm-linux-androideabi
  3. # Where 'arm-linux-androideabi' is the host prefix for the cross-compiler. If
  4. # you already have a toolchain file setup, you may use that instead of this
  5. # file. Make sure to set CMAKE_FIND_ROOT_PATH to where the NDK toolchain was
  6. # installed (e.g. "$ENV{HOME}/toolchains/arm-linux-androideabi-r10c-21").
  7. # the name of the target operating system
  8. SET(CMAKE_SYSTEM_NAME Linux)
  9. # which compilers to use for C and C++
  10. SET(CMAKE_C_COMPILER "${HOST}-clang")
  11. SET(CMAKE_CXX_COMPILER "${HOST}-clang++")
  12. set(CMAKE_SYSTEM_PROCESSOR ${ARCH})
  13. # Starting NDK21 it enables NEON by default on 32-bit ARM target
  14. # Disable it to support more devices
  15. if("${ARCH}" STREQUAL "arm" AND NOT STK_ARM_NEON)
  16. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfpv3-d16")
  17. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfpv3-d16")
  18. endif()
  19. # here is the target environment located
  20. SET(CMAKE_FIND_ROOT_PATH $ENV{NDK_TOOLCHAIN_PATH})
  21. # here is where stuff gets installed to
  22. SET(CMAKE_INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}" CACHE STRING "Install path prefix, prepended onto install directories." FORCE)
  23. # adjust the default behaviour of the FIND_XXX() commands:
  24. # search headers and libraries in the target environment, search
  25. # programs in the host environment
  26. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  27. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  28. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  29. # set env vars so that pkg-config will look in the appropriate directory for
  30. # .pc files (as there seems to be no way to force using ${HOST}-pkg-config)
  31. set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
  32. set(ENV{PKG_CONFIG_PATH} "")