LYWrappers_android.cmake 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. set(LY_STRIP_DEBUG_SYMBOLS FALSE CACHE BOOL "Flag to strip debug symbols from the (non-debug) output binaries")
  9. # Check if 'llvm-strip' is available so that debug symbols can be stripped from output libraries and executables.
  10. find_program(LLVM_STRIP_TOOL llvm-strip)
  11. if (NOT LLVM_STRIP_TOOL)
  12. message(WARNING "Unable to locate 'strip' tool needed to strip debug symbols from the output target(s). "
  13. "Debug symbols will not be removed from output libraries and executables.")
  14. endif()
  15. function(ly_apply_platform_properties target)
  16. # Noop
  17. endfunction()
  18. function(ly_handle_custom_output_directory target output_subdirectory)
  19. if(output_subdirectory)
  20. set_target_properties(${target} PROPERTIES
  21. RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${output_subdirectory}
  22. LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${output_subdirectory}
  23. )
  24. foreach(conf ${CMAKE_CONFIGURATION_TYPES})
  25. string(TOUPPER ${conf} UCONF)
  26. set_target_properties(${target} PROPERTIES
  27. RUNTIME_OUTPUT_DIRECTORY_${UCONF} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_${UCONF}}/${output_subdirectory}
  28. LIBRARY_OUTPUT_DIRECTORY_${UCONF} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${UCONF}}/${output_subdirectory}
  29. )
  30. endforeach()
  31. endif()
  32. endfunction()
  33. #! ly_apply_debug_strip_options: Apply debug stripping options to the target output for non-debug configurations.
  34. #
  35. #\arg:target Name of the target to perform a post-build stripping of any debug symbol)
  36. function(ly_apply_debug_strip_options target)
  37. if (NOT LLVM_STRIP_TOOL)
  38. return()
  39. endif()
  40. if (NOT LY_STRIP_DEBUG_SYMBOLS)
  41. return()
  42. endif()
  43. # If the target is IMPORTED, then there is no post-build process
  44. get_target_property(is_imported ${target} IMPORTED)
  45. if (${is_imported})
  46. return()
  47. endif()
  48. # Check the target type
  49. get_target_property(target_type ${target} TYPE)
  50. # This script only supports executables, applications, modules, and shared libraries
  51. if (NOT ${target_type} STREQUAL "MODULE_LIBRARY" AND
  52. NOT ${target_type} STREQUAL "SHARED_LIBRARY" AND
  53. NOT ${target_type} STREQUAL "EXECUTABLE" AND
  54. NOT ${target_type} STREQUAL "APPLICATION")
  55. return()
  56. endif()
  57. add_custom_command(TARGET ${target} POST_BUILD
  58. COMMAND "${CMAKE_COMMAND}" -P "${LY_ROOT_FOLDER}/cmake/Platform/Android/StripDebugSymbols.cmake"
  59. ${LLVM_STRIP_TOOL}
  60. "$<TARGET_FILE:${target}>"
  61. ${target_type}
  62. COMMENT "Stripping debug symbols ..."
  63. VERBATIM
  64. )
  65. endfunction()