Tests: Fix RunCMake.XcFramework in symlinked paths with Xcode 15

The `xcodebuild -create-xcframework` tool in Xcode 15.0 fails to
compute relative paths if the input paths have symlinks.
This commit is contained in:
Brad King
2023-09-26 11:04:03 -04:00
parent 84a1e529ee
commit 9ba1883ea6

View File

@@ -29,12 +29,21 @@ endfunction()
function(create_xcframework name type platforms)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/create-xcframework-${name}-build)
if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15)
# 'xcodebuild -create-xcframework' fails on symlinked paths.
file(REAL_PATH "${RunCMake_SOURCE_DIR}" src_dir)
file(REAL_PATH "${RunCMake_BINARY_DIR}" bld_dir)
else()
set(src_dir "${RunCMake_SOURCE_DIR}")
set(bld_dir "${RunCMake_BINARY_DIR}")
endif()
set(args)
foreach(platform IN LISTS platforms)
set(lib_dir "${bld_dir}/create-${type}-${platform}-build/install/lib")
if(type STREQUAL "framework")
list(APPEND args -framework ${RunCMake_BINARY_DIR}/create-${type}-${platform}-build/install/lib/mylib.framework)
list(APPEND args -framework ${lib_dir}/mylib.framework)
else()
list(APPEND args -library ${RunCMake_BINARY_DIR}/create-${type}-${platform}-build/install/lib/libmylib.a -headers ${RunCMake_SOURCE_DIR}/mylib/include)
list(APPEND args -library ${lib_dir}/libmylib.a -headers ${src_dir}/mylib/include)
endif()
endforeach()
run_cmake_command(create-xcframework-${name} xcodebuild -create-xcframework ${args} -output ${RunCMake_TEST_BINARY_DIR}/mylib.xcframework)