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

Catalyst - XCode 13.3 - clang: invalid version number in `-target x86_64-apple-ios13.0-macabi` #140

Closed KiruyaMomochi closed 2 years ago

KiruyaMomochi commented 2 years ago

Describe the bug Using XCode 13.3 and building for Catalyst, default deployment target will make clang raise an error.

To Reproduce Steps to reproduce the behavior:

  1. Use XCode 13.3
  2. Build something with platform MAC_CATALYST
  3. Build fails, with error
    FAILED: CMakeFiles/cmTC_48a6c.dir/testCCompiler.c.o
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --target=x86_64-apple-ios13.0-macabi   -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/iOSSupport/usr/include -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/iOSSupport/System/Library/Frameworks -target x86_64-apple-ios13.0-macabi   -fobjc-abi-version=2 -fobjc-arc   -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -MD -MT CMakeFiles/cmTC_48a6c.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_48a6c.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_48a6c.dir/testCCompiler.c.o -c /Users/canarypwn/Desktop/Kyaru/Texture2DDecoder/build/apple-MAC_CATALYST/CMakeFiles/CMakeTmp/testCCompiler.c
    clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi'

Expected behavior It builds successfully.

Environment

xcode version

Xcode 13.3
Build version 13E113

clang version

Apple clang version 13.1.6 (clang-1316.0.21.2)
Target: x86_64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

project(Texture2DDecoderNative) set(CMAKE_CXX_STANDARD 17)

add_compile_definitions(_T2D_DLL)

https://cmake.org/cmake/help/latest/guide/tutorial/Selecting%20Static%20or%20Shared%20Libraries.html

option(BUILD_SHARED_LIBS "Build using shared libraries" ON)

add_library(Texture2DDecoderNative astc.cpp atc.cpp bcn.cpp crunch.cpp dllmain.cpp etc.cpp pvrtc.cpp unitycrunch.cpp)

Important: If compiling with gcc, be sure strict aliasing is disabled: -fno-strict-aliasing

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set_target_properties(Texture2DDecoderNative PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -fno-strict-aliasing") endif()

target_include_directories(Texture2DDecoderNative PRIVATE ${PROJECT_SOURCE_DIR}) install(TARGETS Texture2DDecoderNative DESTINATION ${CMAKE_INSTALL_LIBDIR})

KiruyaMomochi commented 2 years ago

Adding -DDEPLOYMENT_TARGET=14.0 solves it.

See also: https://github.com/passepartoutvpn/openssl-apple/issues/46

leetal commented 2 years ago

Hi! Thanks for reporting this! Will look into what targets that are officially supported by Apple Clang! :)