Install_linux.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #! ly_setup_runtime_dependencies_copy_function_override: Linux-specific copy function to handle RPATH fixes
  9. set(ly_copy_template [[
  10. function(ly_copy source_files relative_target_directory)
  11. set(options)
  12. set(oneValueArgs TARGET_FILE_DIR SOURCE_TYPE SOURCE_GEM_MODULE)
  13. set(multiValueArgs)
  14. cmake_parse_arguments("${CMAKE_CURRENT_FUNCTION}" "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  15. set(target_file_dir "${${CMAKE_CURRENT_FUNCTION}_TARGET_FILE_DIR}")
  16. set(source_type "${${CMAKE_CURRENT_FUNCTION}_SOURCE_TYPE}")
  17. set(source_is_gem "${${CMAKE_CURRENT_FUNCTION}_SOURCE_GEM_MODULE}")
  18. # Create the full path to the target directory
  19. cmake_path(APPEND target_directory "${target_file_dir}" "${relative_target_directory}")
  20. foreach(source_file IN LISTS source_files)
  21. cmake_path(GET source_file FILENAME target_filename)
  22. cmake_path(APPEND full_target_directory "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}" "${target_directory}")
  23. cmake_path(APPEND target_file "${full_target_directory}" "${target_filename}")
  24. if("${source_file}" IS_NEWER_THAN "${target_file}")
  25. message(STATUS "Copying ${source_file} to ${full_target_directory}...")
  26. file(MAKE_DIRECTORY "${full_target_directory}")
  27. file(COPY "${source_file}" DESTINATION "${full_target_directory}" USE_SOURCE_PERMISSIONS FOLLOW_SYMLINK_CHAIN)
  28. file(TOUCH_NOCREATE "${target_file}")
  29. # Special case for install
  30. cmake_PATH(GET source_file EXTENSION target_filename_ext)
  31. if("${target_filename_ext}" STREQUAL ".so")
  32. if("${source_file}" MATCHES "qt/plugins")
  33. file(RPATH_CHANGE FILE "${target_file}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..")
  34. endif()
  35. if(CMAKE_INSTALL_DO_STRIP)
  36. execute_process(COMMAND @CMAKE_STRIP@ "${target_file}")
  37. endif()
  38. elseif("${source_file}" MATCHES "lrelease")
  39. file(RPATH_CHANGE FILE "${target_file}" OLD_RPATH "\$ORIGIN/../lib" NEW_RPATH "\$ORIGIN")
  40. endif()
  41. endif()
  42. endforeach()
  43. endfunction()]])
  44. function(ly_setup_runtime_dependencies_copy_function_override)
  45. string(CONFIGURE "${ly_copy_template}" ly_copy_function_linux @ONLY)
  46. foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES)
  47. string(TOUPPER ${conf} UCONF)
  48. ly_install(CODE "${ly_copy_function_linux}"
  49. COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF}
  50. )
  51. endforeach()
  52. endfunction()
  53. include(cmake/Platform/Common/Install_common.cmake)