ELFTest.cmake.in 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. set(names
  2. elf32lsb.bin
  3. elf32msb.bin
  4. elf64lsb.bin
  5. elf64msb.bin
  6. )
  7. # Prepare binaries on which to operate.
  8. set(in "@CMAKE_CURRENT_SOURCE_DIR@/ELF")
  9. set(out "@CMAKE_CURRENT_BINARY_DIR@/ELF-Out")
  10. file(REMOVE_RECURSE "${out}")
  11. file(MAKE_DIRECTORY "${out}")
  12. foreach(f ${names})
  13. file(COPY ${in}/${f} DESTINATION ${out} NO_SOURCE_PERMISSIONS)
  14. list(APPEND files "${out}/${f}")
  15. endforeach()
  16. foreach(f ${files})
  17. # Check for the initial RPATH.
  18. file(RPATH_CHECK FILE "${f}" RPATH "/sample/rpath")
  19. if(NOT EXISTS "${f}")
  20. message(FATAL_ERROR "RPATH_CHECK removed ${f}")
  21. endif()
  22. # Change the RPATH.
  23. file(RPATH_CHANGE FILE "${f}"
  24. OLD_RPATH "/sample/rpath"
  25. NEW_RPATH "/path1:/path2")
  26. set(rpath)
  27. file(STRINGS "${f}" rpath REGEX "/path1:/path2" LIMIT_COUNT 1)
  28. if(NOT rpath)
  29. message(FATAL_ERROR "RPATH not changed in ${f}")
  30. endif()
  31. # Change the RPATH without compiler defined rpath removed
  32. file(RPATH_CHANGE FILE "${f}"
  33. OLD_RPATH "/path2"
  34. NEW_RPATH "/path3")
  35. set(rpath)
  36. file(STRINGS "${f}" rpath REGEX "/path1:/path3" LIMIT_COUNT 1)
  37. if(NOT rpath)
  38. message(FATAL_ERROR "RPATH not updated in ${f}")
  39. endif()
  40. # Change the RPATH with compiler defined rpath removed
  41. file(RPATH_CHANGE FILE "${f}"
  42. OLD_RPATH "/path3"
  43. NEW_RPATH "/rpath/sample"
  44. INSTALL_REMOVE_ENVIRONMENT_RPATH)
  45. set(rpath)
  46. file(STRINGS "${f}" rpath REGEX "/rpath/sample" LIMIT_COUNT 1)
  47. if(NOT rpath)
  48. message(FATAL_ERROR "RPATH not updated in ${f}")
  49. endif()
  50. file(STRINGS "${f}" rpath REGEX "/path1" LIMIT_COUNT 1)
  51. if(rpath)
  52. message(FATAL_ERROR "RPATH not removed in ${f}")
  53. endif()
  54. # Remove the RPATH.
  55. file(RPATH_REMOVE FILE "${f}")
  56. set(rpath)
  57. file(STRINGS "${f}" rpath REGEX "/rpath/sample" LIMIT_COUNT 1)
  58. if(rpath)
  59. message(FATAL_ERROR "RPATH not removed from ${f}")
  60. endif()
  61. # Check again...this should remove the file.
  62. file(RPATH_CHECK FILE "${f}" RPATH "/sample/rpath")
  63. if(EXISTS "${f}")
  64. message(FATAL_ERROR "RPATH_CHECK did not remove ${f}")
  65. endif()
  66. endforeach()