Open SirLYC opened 2 months ago
try adding your files checking the CMAKE_SYSTEM_PROCESSOR
variable, something like:
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
target_sources(your_target x64/a.c)
else()
target_sources(your_target arm/a.c)
endif()
It's not working...According to https://github.com/leetal/ios-cmake/blob/ad96a372b168930c2a1ff9455e1a9ccb13021617/ios.toolchain.cmake#L815,the CMAKE_SYSTEM_PROCESSOR
is always aarch64
when PLATFORM=SIMULATOR64COMBINED
. And the Cmake config only once.
then I guess the only way is to use xcodebuild's feature to exclude/include source files for a target: EXCLUDED_SOURCE_FILE_NAMES
+ INCLUDED_SOURCE_FILE_NAMES
, see https://developer.apple.com/documentation/xcode/build-settings-reference#Excluded-Source-File-Names
so you'd exclude directory that contains your arch dirs and then include only the necessary arch dir using CURRENT_ARCH
xcodebuild variable, e.g. in terms of xcconfig file that would be:
EXCLUDED_SOURCE_FILE_NAMES = x86_64/* arm64/*
INCLUDED_SOURCE_FILE_NAMES = $(CURRENT_ARCH)/*
My project contains separate code for different CPU architectures, such as x64/a.c for x64 and arm/a.c for arm64. How can I ensure that x64/a.c is compiled only for the x64 simulator and arm/a.c is compiled only for the arm64 target? I've observed that each file has both a compile command with -arch_only x86_64 and -arch_only arm64.
I tried compiling simulator64 and simulatorarm64 separately, but when I attempted to merge them into an xcframework, I encountered an error stating, "Both 'ios-x86_64-simulator' and 'ios-arm64-simulator' represent two equivalent library definitions."
I'm looking forward to your response and appreciate your help.