XcodeIOSInstallCombined-install-check.cmake 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. function(verify_architectures file)
  2. execute_process(
  3. COMMAND xcrun otool -vf ${RunCMake_TEST_BINARY_DIR}/_install/${file}
  4. OUTPUT_VARIABLE otool_out
  5. ERROR_VARIABLE otool_err
  6. RESULT_VARIABLE otool_result)
  7. if(NOT otool_result EQUAL "0")
  8. message(SEND_ERROR "Could not retrieve fat headers: ${otool_err}")
  9. return()
  10. endif()
  11. string(REGEX MATCHALL "\narchitecture [^ \n\t()]+" architectures "${otool_out}")
  12. string(REPLACE "\narchitecture " "" actual "${architectures}")
  13. list(SORT actual)
  14. if(XCODE_VERSION VERSION_LESS 14)
  15. set(maybe_armv7 armv7)
  16. set(maybe_i386 i386)
  17. else()
  18. set(maybe_armv7 "")
  19. set(maybe_i386 "")
  20. endif()
  21. set(expected arm64 ${maybe_armv7} ${maybe_i386} x86_64)
  22. if(NOT actual STREQUAL expected)
  23. message(SEND_ERROR
  24. "The actual library contains the architectures:\n ${actual} \n"
  25. "which do not match expected ones:\n ${expected} \n"
  26. "otool output:\n${otool_out}")
  27. endif()
  28. endfunction()
  29. verify_architectures(bin/foo_app.app/foo_app)
  30. verify_architectures(lib/libfoo_static.a)
  31. verify_architectures(lib/libfoo_shared.dylib)
  32. verify_architectures(lib/foo_bundle.bundle/foo_bundle)
  33. verify_architectures(lib/foo_framework.framework/foo_framework)