ELFTest.cmake.in 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 "/rpath/sample")
  26. set(rpath)
  27. file(STRINGS "${f}" rpath REGEX "/rpath/sample" LIMIT_COUNT 1)
  28. if(NOT rpath)
  29. message(FATAL_ERROR "RPATH not changed in ${f}")
  30. endif()
  31. # Remove the RPATH.
  32. file(RPATH_REMOVE FILE "${f}")
  33. set(rpath)
  34. file(STRINGS "${f}" rpath REGEX "/rpath/sample" LIMIT_COUNT 1)
  35. if(rpath)
  36. message(FATAL_ERROR "RPATH not removed from ${f}")
  37. endif()
  38. # Check again...this should remove the file.
  39. file(RPATH_CHECK FILE "${f}" RPATH "/sample/rpath")
  40. if(EXISTS "${f}")
  41. message(FATAL_ERROR "RPATH_CHECK did not remove ${f}")
  42. endif()
  43. endforeach()