leetal / ios-cmake

A CMake toolchain file for iOS/iPadOS, visionOS, macOS, watchOS & tvOS C/C++/Obj-C++ development
BSD 3-Clause "New" or "Revised" License
1.91k stars 450 forks source link

[bug] Wrong target triplet for simulator #126

Closed guillaume-tgl closed 2 years ago

guillaume-tgl commented 2 years ago

Describe the bug When using SIMULATOR64 or SIMULATORARM64 for the PLATFORM, the target triplet is missing the -simulator suffix. It is set to x86_64-apple-ios${DEPLOYMENT_TARGET} instead of x86_64-apple-ios${DEPLOYMENT_TARGET}-simulator

To Reproduce Steps to reproduce the behavior:

  1. Build libTIFF with -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATORARM64 -DDEPLOYMENT_TARGET=8.0
  2. Build fails with the following error:
[ 44%] Linking C executable raw2tiff
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --target=arm64-apple-ios8.0   -fembed-bitcode -fobjc-abi-version=2 -fobjc-arc  -Wall -Winline -Wformat-security -Wpointer-arith -Wdisabled-optimization -Wno-unknown-pragmas -fstrict-aliasing -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk -mios-simulator-version-min=8.0 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/raw2tiff.dir/raw2tiff.c.o -o raw2tiff  ../libtiff/libtiff.a /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk/usr/lib/libz.tbd
ld: building for iOS, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk/usr/lib/libz.tbd) built for iOS Simulator, file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk/usr/lib/libz.tbd' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected behavior The build should succeed (and it does when appending -simulator to the target triple)

Environment

leetal commented 2 years ago

Hi! Thanks for reporting this! I think that if you use the latest master this issue should now be resolved :)

guillaume-tgl commented 2 years ago

You're right, this is fixed by #123, thanks