Configurations_android.cmake 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  9. # With Android Studio, the CMAKE_RUNTIME_OUTPUT_DIRECTORY, CMAKE_LIBRARY_OUTPUT_DIRECTORY and CMAKE_RUNTIME_OUTPUT_DIRECTORY are
  10. # already different per configuration. There's no need to do "CMAKE_RUNTIME_OUTPUT_DIRECTORY\Debug" as the output folder.
  11. # Having this extra configuration folder creates issues when copying the "runtime dependencies" files into the APK.
  12. foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES)
  13. string(TOUPPER ${conf} UCONF)
  14. unset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${UCONF} CACHE) # Just use the CMAKE_ARCHIVE_OUTPUT_DIRECTORY for all configurations
  15. unset(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${UCONF} CACHE) # Just use the CMAKE_LIBRARY_OUTPUT_DIRECTORY for all configurations
  16. unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${UCONF} CACHE) # Just use the CMAKE_ARCHIVE_OUTPUT_DIRECTORY for all configurations
  17. endforeach()
  18. include(cmake/Platform/Common/Configurations_common.cmake)
  19. include(cmake/Platform/Common/Clang/Configurations_clang.cmake)
  20. set(_android_api_define)
  21. if(${LY_TOOLCHAIN_NDK_PKG_MAJOR} VERSION_LESS "23")
  22. set(_android_api_define __ANDROID_API__=${LY_TOOLCHAIN_NDK_API_LEVEL})
  23. endif()
  24. ly_append_configurations_options(
  25. DEFINES
  26. LINUX64
  27. _LINUX
  28. LINUX
  29. ANDROID
  30. MOBILE
  31. _HAS_C9X
  32. ENABLE_TYPE_INFO
  33. NDK_REV_MAJOR=${LY_TOOLCHAIN_NDK_PKG_MAJOR}
  34. NDK_REV_MINOR=${LY_TOOLCHAIN_NDK_PKG_MINOR}
  35. ${_android_api_define}
  36. COMPILATION
  37. -femulated-tls # All accesses to TLS variables are converted to calls to __emutls_get_address in the runtime library
  38. -ffast-math # Allow aggressive, lossy floating-point optimizations,
  39. -fno-aligned-allocation # Disable use of C++17 aligned_alloc for operator new/delete
  40. COMPILATION_DEBUG
  41. -gdwarf-2 # DWARF 2 debugging information
  42. COMPILATION_PROFILE
  43. -g # debugging information
  44. -gdwarf-2 # DWARF 2 debugging information
  45. LINK_NON_STATIC
  46. -rdynamic # add ALL symbols to the dynamic symbol table
  47. -Wl,--no-undefined # tell the gcc linker to fail if it finds undefined references
  48. -Wl,--gc-sections # discards unused sections
  49. -landroid # Android Library
  50. -llog # log library for android
  51. -lc++_shared
  52. -ldl # Dynamic
  53. -stdlib=libc++
  54. -u ANativeActivity_onCreate
  55. LINK_NON_STATIC_DEBUG
  56. -Wl,--build-id # Android Studio needs the libraries to have an id in order to match them with what"s running on the device.
  57. -shared
  58. LINK_NON_STATIC_PROFILE
  59. -Wl,--build-id # Android Studio needs the libraries to have an id in order to match them with what"s running on the device.
  60. -shared
  61. )
  62. ly_set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions -fno-aligned-allocation -stdlib=libc++")
  63. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
  64. ly_set(CMAKE_CXX_EXTENSIONS OFF)
  65. include(cmake/Platform/Common/TargetIncludeSystemDirectories_supported.cmake)
  66. else()
  67. message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported in ${PAL_PLATFORM_NAME}")
  68. endif()