| 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 |
|
| 12 |
string(REGEX MATCHALL "\narchitecture [^ \n\t()]+" architectures "${otool_out}") |
| 13 |
string(REPLACE "\narchitecture " "" actual "${architectures}") |
| 14 |
list(SORT actual) |
| 15 |
|
| 16 |
if(XCODE_VERSION VERSION_LESS 14) |
| 17 |
set(maybe_armv7 armv7) |
| 18 |
set(maybe_i386 i386) |
| 19 |
else() |
| 20 |
set(maybe_armv7 "") |
| 21 |
set(maybe_i386 "") |
| 22 |
endif() |
| 23 |
set(expected arm64 ${maybe_armv7} ${maybe_i386} x86_64) |
| 24 |
|
| 25 |
if(NOT actual STREQUAL expected) |
| 26 |
message(SEND_ERROR |
| 27 |
"The actual library contains the architectures:\n ${actual} \n" |
| 28 |
"which do not match expected ones:\n ${expected} \n" |
| 29 |
"otool output:\n${otool_out}") |
| 30 |
endif() |
| 31 |
endfunction() |
| 32 |
|
| 33 |
verify_architectures(bin/foo_app.app/foo_app) |
| 34 |
verify_architectures(lib/libfoo_static.a) |
| 35 |
verify_architectures(lib/libfoo_shared.dylib) |
| 36 |
verify_architectures(lib/foo_bundle.bundle/foo_bundle) |
| 37 |
verify_architectures(lib/foo_framework.framework/foo_framework) |