3
0

LYWrappers_android.cmake 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 the target is IMPORTED, then there is no post-build process
  41. get_target_property(is_imported ${target} IMPORTED)
  42. if (${is_imported})
  43. return()
  44. endif()
  45. # Check the target type
  46. get_target_property(target_type ${target} TYPE)
  47. # This script only supports executables, applications, modules, and shared libraries
  48. if (NOT ${target_type} STREQUAL "MODULE_LIBRARY" AND
  49. NOT ${target_type} STREQUAL "SHARED_LIBRARY" AND
  50. NOT ${target_type} STREQUAL "EXECUTABLE" AND
  51. NOT ${target_type} STREQUAL "APPLICATION")
  52. return()
  53. endif()
  54. add_custom_command(TARGET ${target} POST_BUILD
  55. COMMAND "${CMAKE_COMMAND}" -P "${LY_ROOT_FOLDER}/cmake/Platform/Android/StripDebugSymbols.cmake"
  56. ${LLVM_STRIP_TOOL}
  57. "$<TARGET_FILE:${target}>"
  58. ${target_type}
  59. COMMENT "Stripping debug symbols ..."
  60. VERBATIM
  61. )
  62. endfunction()