Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,298
    • Issues 3,298
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 9
    • Merge Requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #21436

Closed
Open
Created Nov 12, 2020 by Chris Ballinger@chrisballinger

Issues with Swift CMAKE_TRY_COMPILE for Mac Catalyst targets

Related issue: #20132

The issue here is that the second -target x86_64-apple-macos10.12 flag (coming from somewhere unknown) is overriding the -target x86_64-apple-ios13.0-macabi we are passing in CMAKE_Swift_FLAGS (which translates to OTHER_SWIFT_FLAGS in Xcode).

See in log below:

CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'cmTC_15e27' from project 'CMAKE_TRY_COMPILE')
    cd /Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp
    export DEVELOPER_DIR\=/Applications/Xcode-12.1.1.app/Contents/Developer
    export SDKROOT\=/Applications/Xcode-12.1.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
    /Applications/Xcode-12.1.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name cmTC_15e27 -O -enable-batch-mode -enforce-exclusivity\=checked @/Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_15e27.build/Objects-normal/x86_64/cmTC_15e27.SwiftFileList -target x86_64-apple-ios13.0-macabi -sdk /Applications/Xcode-12.1.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -target x86_64-apple-macos10.12 -g -module-cache-path /Users/chrisbal/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -swift-version 4 -I /Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/Debug -F /Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/Debug -c -j12 -output-file-map /Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_15e27.build/Objects-normal/x86_64/cmTC_15e27-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_15e27.build/Objects-normal/x86_64/cmTC_15e27.swiftmodule -Xcc -I/Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_15e27.build/swift-overrides.hmap -Xcc -I/Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/Debug/include -Xcc -I/Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_15e27.build/DerivedSources-normal/x86_64 -Xcc -I/Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_15e27.build/DerivedSources/x86_64 -Xcc -I/Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_15e27.build/DerivedSources -Xcc -DCMAKE_INTDIR\=\"Debug\" -emit-objc-header -emit-objc-header-path /Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_15e27.build/Objects-normal/x86_64/cmTC_15e27-Swift.h -working-directory /Users/chrisbal/Documents/opencv-build/build/build-x86_64-catalyst/modules/objc/framework_build/CMakeFiles/CMakeTmp

What is possibly a related issue, is that it's not valid to make command line tools for iOS-style targets (like Catalyst), which is what this CMAKE_TRY_COMPILE project is doing.

I even tried forcing the target destination to platform=macOS,arch=x86_64,variant=Mac Catalyst, but it didn't have any effect:

$ xcodebuild -project CMAKE_TRY_COMPILE.xcodeproj/ -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' build

I've attached the CMAKE_TRY_COMPILE.xcodeproj as CMakeTmp.zip below, which may help diagnosing this issue.

CMakeError.log CMakeOutput.log

CMakeTmp.zip

You can reproduce with the following (see WIP PR here):

$ git clone https://github.com/Rightpoint/opencv.git
$ cd opencv
$ git checkout feature/chrisballinger/build-catalyst-xcframework
$ python3 platforms/osx/build_framework.py --catalyst_archs x86_64 --build-only-specified-archs ../opencv-build/

In the meantime I am going to try working around the issue by not overriding CMAKE_EXE_LINKER_FLAGS (which includes passing -target x86_64-apple-ios13.0-macabi to LDFLAGS) and injecting that manually via the xcodebuild command after CMake has finished project generation.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None