android.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright 2021 The Draco Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not
  4. # use this file except in compliance with the License. You may obtain a copy of
  5. # the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations under
  13. # the License.
  14. if(DRACO_CMAKE_TOOLCHAINS_ANDROID_CMAKE_)
  15. return()
  16. endif() # DRACO_CMAKE_TOOLCHAINS_ANDROID_CMAKE_
  17. # Additional ANDROID_* settings are available, see:
  18. # https://developer.android.com/ndk/guides/cmake#variables
  19. if(NOT ANDROID_PLATFORM)
  20. set(ANDROID_PLATFORM android-21)
  21. endif()
  22. # Choose target architecture with:
  23. #
  24. # -DANDROID_ABI={armeabi-v7a,armeabi-v7a with NEON,arm64-v8a,x86,x86_64}
  25. if(NOT ANDROID_ABI)
  26. set(ANDROID_ABI arm64-v8a)
  27. endif()
  28. # Force arm mode for 32-bit arm targets (instead of the default thumb) to
  29. # improve performance.
  30. if(ANDROID_ABI MATCHES "^armeabi" AND NOT ANDROID_ARM_MODE)
  31. set(ANDROID_ARM_MODE arm)
  32. endif()
  33. # Toolchain files do not have access to cached variables:
  34. # https://gitlab.kitware.com/cmake/cmake/issues/16170. Set an intermediate
  35. # environment variable when loaded the first time.
  36. if(DRACO_ANDROID_NDK_PATH)
  37. set(ENV{DRACO_ANDROID_NDK_PATH} "${DRACO_ANDROID_NDK_PATH}")
  38. else()
  39. set(DRACO_ANDROID_NDK_PATH "$ENV{DRACO_ANDROID_NDK_PATH}")
  40. endif()
  41. if(NOT DRACO_ANDROID_NDK_PATH)
  42. message(FATAL_ERROR "DRACO_ANDROID_NDK_PATH not set.")
  43. return()
  44. endif()
  45. include("${DRACO_ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake")