A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

Overview

A CMake toolchain file for iOS (+ Catalyst), watchOS, tvOS and macOS development with full simulator support and toggleable options!

NEW!

  • Experimental Catalyst support (iOS on macOS)
  • macOS support and experimental Apple Silicon support
  • Deprecated options now removed.

ios-cmake

Build Status

Tested with the following combinations:

  • XCode 8.3, iOS SDK 10.3
  • XCode 9.4, iOS SDK 11.4
  • XCode 10.2, iOS SDK 12.2
  • XCode 11.1, iOS SDK 13.1
  • XCode 11.3, iOS SDK 13.3
  • XCode 12.4, iOS/iPadOS SDK 14.4, tvOS 14.3, watchOS 7.2, macOS SDK 11.1

Platform flag options (-DPLATFORM=flag)

  • OS - to build for iOS (armv7, armv7s, arm64) DEPRECATED in favour of OS64
  • OS64 - to build for iOS (arm64 only)
  • OS64COMBINED - to build for iOS & iOS Simulator (FAT lib) (arm64, x86_64)
  • SIMULATOR - to build for iOS simulator 32 bit (i386) DEPRECATED
  • SIMULATOR64 - to build for iOS simulator 64 bit (x86_64)
  • SIMULATORARM64 - to build for iOS simulator 64 bit (arm64)
  • TVOS - to build for tvOS (arm64)
  • TVOSCOMBINED - to build for tvOS & tvOS Simulator (arm64, x86_64)
  • SIMULATOR_TVOS - to build for tvOS Simulator (x86_64)
  • WATCHOS - to build for watchOS (armv7k, arm64_32)
  • WATCHOSCOMBINED - to build for watchOS & Simulator (armv7k, arm64_32, i386)
  • SIMULATOR_WATCHOS - to build for watchOS Simulator (i386)
  • MAC - to build for macOS (x86_64)
  • MAC_ARM64 - to build for macOS on Apple Silicon (arm64)
  • MAC_CATALYST - to build iOS for Mac (Catalyst, x86_64)
  • MAC_CATALYST_ARM64 - to build iOS for Mac on Apple Silicon (Catalyst, arm64)

Example usage

NOTE: Change the -DPLATFORM to an applicable value if targeting another platform.

cd example/example-lib
mkdir build
cd build
cmake .. -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DPLATFORM=OS64
cmake --build . --config Release

This will build and install the library for the given PLATFORM. In this case, iOS with the arm64 architecture.

COMBINED Options

The options called *COMBINED (OS64COMBINED, TVOSCOMBINED and WATCHOSCOMBINED) will build complete FAT-libraries for the given platform. These FAT-libraries include slices for both device and simulator, making the distribution and usage of the library much more simple!

Example:

cmake . -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DPLATFORM=OS64COMBINED
cmake --build . --config Release
cmake --install . --config Release

NOTE: The COMBINED options ONLY work with the Xcode generator (-G Xcode) on CMake versions 3.14+!


Exposed Variables

XCODE_VERSION - Version number (not including Build version) of Xcode detected.

SDK_VERSION - Version of SDK being used.

CMAKE_OSX_ARCHITECTURES - Architectures being compiled for (generated from PLATFORM).

APPLE_TARGET_TRIPLE - Used by autoconf build systems.

Additional Options

-DENABLE_BITCODE=(BOOL) - Enabled by default, specify FALSE or 0 to disable bitcode

-DENABLE_ARC=(BOOL) - Enabled by default, specify FALSE or 0 to disable ARC

-DENABLE_VISIBILITY=(BOOL) - Disabled by default, specify TRUE or 1 to enable symbol visibility support

-DENABLE_STRICT_TRY_COMPILE=(BOOL) - Disabled by default, specify TRUE or 1 to enable strict compiler checks (will run linker on all compiler checks whenever needed)

-DARCHS=(STRING) - Valid values are: armv7, armv7s, arm64, i386, x86_64, armv7k, arm64_32. By default it will build for all valid architectures based on -DPLATFORM (see above)

To combine all platforms into the same FAT-library, either build any of the "COMBINED" platform types OR use the LIPO tool. More information on how to combine libraries with LIPO is readily available on the net.

Thanks To

Comments
  • Add Catalyst support (UIKit on macOS)

    Add Catalyst support (UIKit on macOS)

    This seems possible via -target x86_64-apple-ios-macabi -miphoneos-version-min=13.0. Adding it to CFLAGS and LDFLAGS should be sufficient, although untested.

    enhancement 
    opened by leetal 11
  • Invalid iOS deployment version

    Invalid iOS deployment version

    Hi, I tried to get your iOS CMake Toolchain running but I always get the same error:

    clang: error: invalid iOS deployment version '-mios-simulator-version-min=12.1',
    iOS 10 is the maximum deployment target for 32-bit targets
    [-Winvalid-ios-deployment-target]
    

    I know 32-bit targets are no longer supported, but I don't understand why the CMake build always sets this target (i.e. i386). No matter if I set IOS_PLATFORM macro to OS or SIMULATOR64.

    I also tried different deployment targets: 8.0, 10.0, 12.0, and 12.1. But since SDK 12.1 is my only installed SDK, the CMake build can only use this one.

    Can anyone tell me what I'm doing wrong?

    bug 
    opened by LukasBanana 10
  • cmake error

    cmake error

    there is an error occur when i build the google test and avs-device-sdk

    I enter the command on the command line: cmake ../googletest -DIOS_DEPLOYMENT_TARGET=10.0 -DCMAKE_TOOLCHAIN_FILE=../ios-cmake/ios.toolchain.cmake -DIOS_PLATFORM=OS or cmake ../avs-device-sdk -DIOS_DEPLOYMENT_TARGET=10.0 -DCMAKE_TOOLCHAIN_FILE=../ios-cmake/ios.toolchain.cmake -DIOS_PLATFORM=OS -DGSTREAMER_MEDIA_PLAYER=OFF -DCURL_LIBRARY=../Build-OpenSSL-cURL/archive/libcurl-7.54.1-openssl-1.0.2l-nghttp2-1.24.0/libcurl_iOS.a -DCURL_INCLUDE_DIR=../Build-OpenSSL-cURL/curl/curl-7.55.1/include -DGTEST_LIBRARY=../googletest_build/googlemock/libgmock.a -DGTEST_MAIN_LIBRARY=../googletest_build/googlemock/libgmock_main.a -DGTEST_INCLUDE_DIR=../googletest/googletest/include/ -DPKG_CONFIG_EXECUTABLE=/usr/local/bin/pkg-config

    error is:

    -- Building with Xcode version: -- Configuring iOS build for platform: SIMULATOR64, architecture(s): x86_64 -- Using SDK: for platform: SIMULATOR64 CMake Error at ../ios-cmake/ios.toolchain.cmake:172 (message): Invalid CMAKE_OSX_SYSROOT: does not exist. Call Stack (most recent call first): /usr/local/Cellar/cmake/3.11.3/share/cmake/Modules/CMakeDetermineSystem.cmake:94 (include) CMakeLists.txt:4 (project)

    CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!

    How can I build it successfully?

    opened by wanJunGe 10
  • CMake fails to find XCTest (3.0.1 release)

    CMake fails to find XCTest (3.0.1 release)

    Hello,

    I tried the recent 3.0.1 update, and encountered an issue I can't fix.

    For some part of my code, I use CMake to create XCTest targets with your toolchain using XCode generator. For this, I add find_package(XCTest REQUIRED) in my CMakeLists, and use the functions xctest_add_bundle and xctest_add_test to generator my XCTest targets.

    Everything worked fine, but when I updated the toolchain from 2.2.0 to the 3.0.1 and changed IOS_PLATFORM to PLATFORM in my Cmake build scrits, I obtained the following error :

    CMake Error at /usr/local/Cellar/cmake/3.14.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
      Could NOT find XCTest (missing: XCTest_LIBRARY XCTest_INCLUDE_DIR)
    Call Stack (most recent call first):
      /usr/local/Cellar/cmake/3.14.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
      /usr/local/Cellar/cmake/3.14.1/share/cmake/Modules/FindXCTest.cmake:84 (find_package_handle_standard_args)
      MWMAudioKit/MWMAudioKit_Core/CoreMathVector-Tests/CMakeLists.txt:30 (find_package)
    

    I'm running CMake 3.14.1 and I have XCode 10.2 with iOS SDK 12.2 installed.

    I looked at the diff of your release and tried a few things but couldn't find any solution. Any idea of something I or you did wrong ?

    Thanks again for your work :)

    Tom

    bug upstream fix needed 
    opened by ThomasHezard 9
  • Use CMAKE_IOS_INSTALL_COMBINED CMake Variable for Universal Library Support Out-of-the-Box

    Use CMAKE_IOS_INSTALL_COMBINED CMake Variable for Universal Library Support Out-of-the-Box

    Since CMake 3.5.2, it seems CMake has support for Universal fat libraries out-of-the-box. This can be set with CMAKE_IOS_INSTALL_COMBINED.

    From the official documentation for the target property IOS_INSTALL_COMBINED:

    When this property is set to set to false (which is the default) then it will either be built with the device SDK or the simulator SDK depending on the SDK set. But if this property is set to true then the target will at install time also be built for the corresponding SDK and combined into one library.

    This feature requires at least Xcode version 6.

    Internally, it seems to create an install task on the target to build for all the supplied Apple Device SDKs then combine all the binaries into 1 fat binary using lipo.

    I haven't actually started using this variable yet, and I'm not exactly sure how it would even fit with the current toolchain, but if I can figure it out before someone else investigates it, I'm willing to create a pull request.

    enhancement 
    opened by epicstar 9
  • Recent addition of CMAKE_SYSTEM_PROCESSOR breaks some build

    Recent addition of CMAKE_SYSTEM_PROCESSOR breaks some build

    It seems to me that the recent addition (solving #40) of CMAKE_SYSTEM_PROCESSOR breaks some build.

    I am not sure why, so here is a reproducible example:

    1. Use the latest ios.toolchain.cmake file
    2. Use the following CMakeLists.txt, which will basically download and build libressl
    3. Run cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/ios.toolchain.cmake ..

    CMakeLists.txt

    cmake_minimum_required(VERSION 3.1)
      
    project(external-libressl)
    include(ExternalProject)
    
    set(LIBRESSL_VERSION 2.9.0)
    
    list(APPEND CMAKE_ARGS
        "-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}"
        "-DBUILD_SHARED_LIBS=OFF"
        "-DLIBRESSL_APPS=OFF"
        "-DLIBRESSL_TESTS=OFF"
        )
    
    if(IOS)
        list(APPEND CMAKE_ARGS
            "-DPLATFORM=${PLATFORM}"
            "-DCMAKE_C_FLAGS=-Wno-implicit-function-declaration"
            )
    endif()
    
    message(STATUS "Preparing external project \"libressl\" with args:")
    foreach(CMAKE_ARG ${CMAKE_ARGS})
        message(STATUS "-- ${CMAKE_ARG}")
    endforeach()
    
    ExternalProject_add(
        libressl
        URL https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz
        PREFIX libressl
        CMAKE_ARGS "${CMAKE_ARGS}"
        )
    

    The error I get:

    [ 75%] Performing build step for 'libressl'
    Scanning dependencies of target crypto
    [  0%] Building C object crypto/CMakeFiles/crypto.dir/aes/aes-elf-armv4.S.o
    /tmp/demo_libressl/build/libressl/src/libressl/crypto/aes/aes-elf-armv4.S:1:10: fatal error: 'arm_arch.h' file not found
    #include "arm_arch.h"
             ^~~~~~~~~~~~
    

    Removing this addition of CMAKE_SYSTEM_PROCESSOR fixes it, I have no idea why.

    opened by JonasVautherin 8
  • Need an option to build OS64 libraries without code signing

    Need an option to build OS64 libraries without code signing

    Describe the bug If you are trying to build OS64 or any platform which is not a simulator, you will be forced to code sign the output. When building from a Mac without code signing certificate (no Apple developer account), the CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM will be set as "123456789A" and the build will fail with error message,

    Code Signing Error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "123456789A" with a private key was found.

    To Reproduce Steps to reproduce the behavior:

    1. Build any project for device (not simulator) such as OS64 without providing CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM

    Expected behavior Be able build without code signing. Not every libraries are required to be code signed, for example,

    • Static linked libraries do not require code signing
    • App developers may choose to code sign the dynamic library manually late
    • For CIs verifying building, adding code signing will be extra work without obvious benefits

    Environment

    • What version of CMake did you run?
    • Your faulty CMakeLists.txt here:
    --- Paste here ---
    

    Proposal Add an extra option to disable code signing, if CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM is not set. Can send PR

    bug 
    opened by guoyu-wang 7
  • Error

    Error "invalid argument '-mmacosx-version-min=9.0'"

    I'm using CMake with ios-cmake (3.1.0) inside an Xcode Run Script build phase, to build a 3rd party static library my target links with. However, Clang immediately fails with:

    clang: error: invalid argument '-mmacosx-version-min=9.0' not allowed with '-mios-simulator-version-min=9.0'

    The problem appears to be caused by this statement in ios.toolchain.cmake:

    https://github.com/leetal/ios-cmake/blob/8f7c16a462d17eba7124aba921153382605df288/ios.toolchain.cmake#L545-L546

    If I comment out those two lines, everything builds fine. It seems wrong for the script to be forcing a macOS deployment target when it's not building for macOS, but somehow I'm the only one having trouble as a result...

    Here's the full CMake output:

    CMake options:                  -DCMAKE_TOOLCHAIN_FILE=vendor/ios-cmake/ios.toolchain.cmake                 -DPLATFORM=SIMULATOR64             -DENABLE_PROGRAMS=0             -DENABLE_TESTING=0 -DCMAKE_BUILD_TYPE=Debug -DLWS_WITH_ASAN=1
    -- Building with Xcode version: 11.2.1
    -- Configuring iphonesimulator build for platform: SIMULATOR64, architecture(s): x86_64
    -- Using SDK: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk for platform: SIMULATOR64
    -- Using the default min-version since DEPLOYMENT_TARGET not provided!
    -- Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!
    -- Enabling ARC support by default. ENABLE_ARC not provided!
    -- Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!
    -- Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!
    -- Using C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
    -- Using CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
    -- Using libtool: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
    -- Using install_name_tool: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool
    -- Using a data_ptr size of 8
    -- Building for minimum iphonesimulator version: 9.0 (SDK version: 13.2)
    -- Version flags set to: -mios-simulator-version-min=9.0
    -- Disabling bitcode support.
    -- Enabling ARC support.
    -- Hiding symbols (-fvisibility=hidden).
    -- Building with Xcode version: 11.2.1
    -- Configuring iphonesimulator build for platform: SIMULATOR64, architecture(s): x86_64
    -- Using SDK: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk for platform: SIMULATOR64 when checking compatibility
    -- Using libtool: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
    -- Using a data_ptr size of 8
    -- Building for minimum iphonesimulator version: 9.0 (SDK version: 13.2)
    -- Version flags set to: -mios-simulator-version-min=9.0
    -- Disabling bitcode support.
    -- Enabling ARC support.
    -- Hiding symbols (-fvisibility=hidden).
    -- The C compiler identification is AppleClang 11.0.0.11000033
    -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
    -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- broken
    CMake Error at /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/CMakeTestCCompiler.cmake:51 (message):
      The C compiler
      "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
      is not able to compile a simple test program.
    
      It fails with the following output:
    
       Change Dir: /Users/snej/Couchbase/CBL/couchbase-lite-ios/build/CouchbaseLite/Build/Intermediates.noindex/LiteCore.build/Debug-iphonesimulator/mbedTLS.build/Objects/mbedtls/CMakeFiles/CMakeTmp
    
      
    
      Run Build Command:"/Applications/Xcode.app/Contents/Developer/usr/bin/make"
      "cmTC_823d2/fast"
    
      /Applications/Xcode.app/Contents/Developer/usr/bin/make -f
      CMakeFiles/cmTC_823d2.dir/build.make CMakeFiles/cmTC_823d2.dir/build
    
      Building C object CMakeFiles/cmTC_823d2.dir/testCCompiler.c.o
    
      
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
      -mios-simulator-version-min=9.0 -fobjc-abi-version=2 -fobjc-arc
      -mios-simulator-version-min=9.0 -fobjc-abi-version=2 -fobjc-arc -arch
      x86_64 -isysroot
      /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk
      -mmacosx-version-min=9.0 -o CMakeFiles/cmTC_823d2.dir/testCCompiler.c.o -c
      /Users/snej/Couchbase/CBL/couchbase-lite-ios/build/CouchbaseLite/Build/Intermediates.noindex/LiteCore.build/Debug-iphonesimulator/mbedTLS.build/Objects/mbedtls/CMakeFiles/CMakeTmp/testCCompiler.c
    
    
      clang: error: invalid argument '-mmacosx-version-min=9.0' not allowed with
      '-mios-simulator-version-min=9.0'
    
    opened by snej 7
  • Overwriting CMAKE_OSX_SYSROOT with an invalid value

    Overwriting CMAKE_OSX_SYSROOT with an invalid value

    Here in the commit CMAKE_OSX_SYSROOT becomes like

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk
    

    All is OK.

    But here in the commit CMAKE_OSX_SYSROOT becomes like

    iphonesimulator
    

    For what purpose?

    And further work is done with CMAKE_OSX_SYSROOT as a path to a file, rather than as the name of the SDK.

    opened by NikitaFeodonit 7
  • Problems with simple C++ sample and your toolkit (FAT/COMBINED)

    Problems with simple C++ sample and your toolkit (FAT/COMBINED)

    Hi,

    First, you make a great toolkit, good job!

    Second, im trying use your toolkit to build a simple FAT/COMBINED library and use on xcode.

    The problem is that generated library is only with one "arch".

    There is a test on my sample repository, and the problem can be checked there: https://travis-ci.com/prsolucoes/ios-lib-test/builds/138626985#L873

    Im calling your toolkit with the params: https://github.com/prsolucoes/ios-lib-test/blob/master/Makefile#L24

    It is strange, because if i run install it generate the library into system folder with all archs inside: /usr/local/lib/libcpp_lib_test.a

    The command to install is here: https://github.com/prsolucoes/ios-lib-test/blob/master/Makefile#L40

    Can you help me understand the problem?

    Thanks.

    opened by paulocoutinhox 6
  • iphoneos is not an iOS SDK

    iphoneos is not an iOS SDK

    Building example-lib get an error:

    CMake Error at /usr/local/Cellar/cmake/3.14.5/share/cmake/Modules/Platform/iOS-Initialize.cmake:4 (message):
      iphoneos is not an iOS SDK
    Call Stack (most recent call first):
      /usr/local/Cellar/cmake/3.14.5/share/cmake/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
      CMakeLists.txt:2 (project)
    

    use cmake 3.15.rc not working. can some one help me?

    opened by syq7970 6
  • [question] Issue with APPLE_TARGET_TRIPLE (aarch64-apple-ios/arm64-apple-ios)

    [question] Issue with APPLE_TARGET_TRIPLE (aarch64-apple-ios/arm64-apple-ios)

    I'm new to cross-compiling so I may be doing something wrong. I've tried using this toolchain together with cmake-conan script. I'm having problem with auto-detecting of compiler here: https://github.com/conan-io/cmake-conan/blob/835529148ac0def63bbd1d07ceb4e4c130d233af/conan.cmake#L370 In my case: cmake -E echo "#include <string>" | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ --target=aarch64-apple-ios11.0 -fvisibility=hidden -fvisibility-inlines-hidden -x c++ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk -E -dM - This leads to error: unknown target triple 'unknown-apple-ios11.0.0', please use -triple or -arch

    I've tried googling and found this issue https://groups.google.com/g/llvm-dev/c/PIBNR1EE9R0 Running the same command with arm64-apple-ios11.0 instead of aarch64-apple-ios11.0 seems to be working. cmake -E echo "#include <string>" | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ --target=arm64-apple-ios11.0 -fvisibility=hidden -fvisibility-inlines-hidden -x c++ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk -E -dM -

    So should something be changed in cmake-conan or in this toolchain (maybe CMAKE_CXX_COMPILER_TARGET should be different in this case)?

    -- Using Xcode version: 12.0.1 -- CMake version: 3.23.1

    bug 
    opened by Nekto89 5
  • [bug] The platform OS64COMBINED generate Xcode project only for iOS

    [bug] The platform OS64COMBINED generate Xcode project only for iOS

    Describe the bug

    When i use -DPLATFORM=OS64COMBINED and generate Xcode project, it only create the project with BASE SDK equal iOS.

    image

    To Reproduce Steps to reproduce the behavior:

    cmake -B build -GXcode -DCMAKE_TOOLCHAIN_FILE=cmake/ios.toolchain.cmake -DPLATFORM=OS64COMBINED

    Expected behavior

    Use BASE SDK iOS for arm64 and iOS Simulator for x86_64.

    Environment

    • What version of CMake did you run? 3.23.2

    LOG:

    -- Not setting any manual command-line buildflags, since Xcode is selected as generator. Modifying the Xcode build-settings directly instead.
    -- Configuring iphoneos build for platform: OS64COMBINED, architecture(s): arm64;x86_64
    -- Using SDK: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk
    -- Using C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
    -- Using CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
    -- Using libtool: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
    -- Using install name tool: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool
    -- Autoconf target triple: aarch64-x86_64-apple-ios9.0
    -- Using minimum deployment version: 9.0 (SDK version: 16.0)
    -- Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!
    -- Will combine built (static) artifacts into FAT lib...
    -- Using Xcode version: 14.0
    -- CMake version: 3.23.2
    -- Using a data_ptr size of: 8
    -- Bitcode: Disabled
    -- ARC: Disabled
    -- Hiding symbols: Enabled
    -- The C compiler identification is AppleClang 14.0.0.14000029
    -- The CXX compiler identification is AppleClang 14.0.0.14000029
    
    bug 
    opened by paulocoutinhox 1
  • [bug] Should set ENABLE_STRICT_TRY_COMPILE TRUE by default

    [bug] Should set ENABLE_STRICT_TRY_COMPILE TRUE by default

    Describe the bug Sets ENABLE_STRICT_TRY_COMPILE OFF default, will lead cmake generate incorrect native project for dynamic libraries.

    To Reproduce Steps to reproduce the behavior:

    1. https://github.com/axys1/axys/runs/8269974724?check_suite_focus=true

    Expected behavior Generate native project correct when build dynamic library on iOS.

    Environment

    • What version of CMake did you run?
    • Your faulty CMakeLists.txt here:
    git clone https://github.com/kcat/openal-soft
    cd openal-soft
    cmake -B build -GXcode -DCMAKE_TOOLCHAIN_FILE=ios.cmake.toolchain -DPLATFORM=OS64
    cmake --build build --target OpenAL
    # will error with: ld: library not found for -latomic, because the openal-soft find non-exists library `libatomic` with this toolchain file
    
    bug 
    opened by halx99 5
  • Cannot run app from installdir, but from build-Release

    Cannot run app from installdir, but from build-Release

    I have tweaked the CMakeLists.txt from the example in order to link to OpenCV. This seems to work for ios and mac. I can run the toy code on the simulator.

    An issue though is that if I build with -DCMAKE_INSTALL_PREFIX=../mac-lib and -DPLATFORM=MAC_ARM64, then I cannot run the executable under ./mac-lib/Test.App/Contents/MacOS/TestApp. But I can run ./build/Release/Contents/MacOS/TestApp.

    When I run from mac-lib I get:

    Translated Report (Full Report Below)
    -------------------------------------
    
    Incident Identifier: 7BC035B9-D9BF-463A-821F-F89B8C4DFFEB
    CrashReporter Key:   21F36FD2-7188-AE2F-1B85-FE079442FAD3
    Hardware Model:      MacBookAir10,1
    Process:             TestApp [49666]
    Path:                /Users/USER/*/TestApp.app/Contents/MacOS/TestApp
    Identifier:          leetal.com.helloworld
    Version:             0.1 (0.1)
    Code Type:           ARM-64 (Native)
    Role:                Default
    Parent Process:      launchd [1]
    Coalition:           leetal.com.helloworld [32208]
    
    Date/Time:           2022-08-21 22:11:01.1997 +0200
    Launch Time:         2022-08-21 22:11:01.1853 +0200
    OS Version:          macOS 12.5 (21G72)
    Release Type:        User
    Report Version:      104
    
    Exception Type:  EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
    Exception Subtype: UNKNOWN_0x32 at 0x00000001049bc000
    Exception Codes: 0x0000000000000032, 0x00000001049bc000
    VM Region Info: 0x1049bc000 is in 0x1049bc000-0x1049c0000;  bytes after start: 0  bytes before end: 16383
          REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
          UNUSED SPACE AT START
    --->  mapped file                 1049bc000-1049c0000    [   16K] r-x/r-x SM=COW  ...t_id=ad270cb7
          mapped file                 1049c0000-1049c4000    [   16K] rw-/rw- SM=COW  ...t_id=ad270cb7
    Exception Note:  EXC_CORPSE_NOTIFY
    Termination Reason: CODESIGNING 2 
    
    Highlighted by Thread:  0
    
    Backtrace not available
    

    The CMakeLists.txt is looking like this (I have added OpenCV on different places and the project name):

    cmake_minimum_required (VERSION 3.2)
    project (videoprocessing-ios)
    enable_testing()
    
    enable_language(CXX)
    enable_language(OBJC)
    
    MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
    MESSAGE( STATUS "CMAKE_OBJC_FLAGS: " ${CMAKE_OBJC_FLAGS} )
    
    # Add some sanitary checks that the toolchain is actually working!
    include(CheckCXXSymbolExists)
    check_cxx_symbol_exists(kqueue sys/event.h HAVE_KQUEUE)
    if(NOT HAVE_KQUEUE)
      message(STATUS "kqueue NOT found!")
    else()
      message(STATUS "kqueue found!")
    endif()
    
    find_library(APPKIT_LIBRARY AppKit)
    if (NOT APPKIT_LIBRARY)
      message(STATUS "AppKit.framework NOT found!")
    else()
      message(STATUS "AppKit.framework found! ${APPKIT_LIBRARY}")
    endif()
    
    find_library(FOUNDATION_LIBRARY Foundation)
    if (NOT FOUNDATION_LIBRARY)
      message(STATUS "Foundation.framework NOT found!")
    else()
      message(STATUS "Foundation.framework found! ${FOUNDATION_LIBRARY}")
    endif()
    
    find_library(UIKIT_LIBRARY UIKit)
    if (NOT UIKIT_LIBRARY)
      message(STATUS "UIKit.framework NOT found!")
    else()
      message(STATUS "UIKit.framework found! ${UIKIT_LIBRARY}")
    endif()
    
    # Hook up XCTest for the supported plaforms (all but WatchOS)
    if(NOT PLATFORM MATCHES ".*WATCHOS.*")
      # Use the standard find_package, broken between 3.14.0 and 3.14.4 at least for XCtest...
      find_package(XCTest)
      # Fallback: Try to find XCtest as host package via toochain macro (should always work)
      find_host_package(XCTest REQUIRED)
    endif()
    
    # Includes
    include_directories(${CMAKE_SOURCE_DIR}/include)
    
    # Make sure try_compile() works
    include(CheckTypeSize)
    check_type_size(time_t SIZEOF_TIME_T)
    
    #OpenCV
    find_package( OpenCV REQUIRED PATHS "thirdparty/installdir/opencv_mac/lib/cmake/opencv4/" NO_DEFAULT_PATH)
    include_directories( ${OpenCV_INCLUDE_DIRS} )
    
    # Source files
    set(SOURCES
      src/VideoProcessing.cpp
      src/VideoProcessingWrapperObjC.mm
    )
    
    # Headers
    set(HEADERS
      include/VideoProcessing.hpp
      include/VideoProcessingWrapperObjC.h
    )
    
    # Library
    if(BUILD_SHARED)
      add_library (videoprocessing SHARED ${SOURCES} ${HEADERS})
      target_link_libraries(videoprocessing ${FOUNDATION_LIBRARY} ${OpenCV_LIBS})
      target_compile_definitions(videoprocessing PUBLIC IS_BUILDING_SHARED)
      message(STATUS "Building shared version...")
    else()
      add_library (videoprocessing STATIC ${SOURCES} ${HEADERS})
      target_link_libraries(videoprocessing ${FOUNDATION_LIBRARY} ${OpenCV_LIBS})
      message(STATUS "Building static version...")
    endif()
    
    if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
      set(CMAKE_INSTALL_PREFIX ${videoprocessing-ios_SOURCE_DIR}/../videoprocessing-app/videoprocessing-lib CACHE PATH "Install path" FORCE)
    endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
    
    # Executable
    if(PLATFORM MATCHES "MAC.*")
      set(APP_NAME TestApp)
      add_executable (${APP_NAME} MACOSX_BUNDLE src/main.cpp)
      set_target_properties(${APP_NAME} PROPERTIES
              BUNDLE True
              MACOSX_BUNDLE_GUI_IDENTIFIER leetal.com.helloworld
              MACOSX_BUNDLE_BUNDLE_NAME helloworld
              MACOSX_BUNDLE_BUNDLE_VERSION "0.1"
              MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1"
              )
      # Link the library with the executable
      target_link_libraries(${APP_NAME} videoprocessing ${OpenCV_LIBS})
    endif()
    
    # Debug symbols set in XCode project
    set_xcode_property(videoprocessing GCC_GENERATE_DEBUGGING_SYMBOLS YES "All")
    
    # Installation
    if(PLATFORM MATCHES "MAC.*")
      install(TARGETS ${APP_NAME}
              BUNDLE DESTINATION . COMPONENT Runtime
              RUNTIME DESTINATION bin COMPONENT Runtime
              LIBRARY DESTINATION lib
              ARCHIVE DESTINATION lib/static)
    
      # Note Mac specific extension .app
      set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_NAME}.app")
    
      # Directories to look for dependencies
      set(DIRS ${CMAKE_BINARY_DIR} ${OpenCV_INSTALL_PATH}/lib)
    
      install(CODE "include(BundleUtilities)
        fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")")
    
      set(CPACK_GENERATOR "DRAGNDROP")
      include(CPack)
    else()
      install(TARGETS videoprocessing
              LIBRARY DESTINATION lib
              ARCHIVE DESTINATION lib/static)
    endif()
    install (FILES ${HEADERS} DESTINATION include)
    

    The error says it is related to code signing, but why would that not apply to the executable in the build library?

    opened by bylowerik 1
  • [bug] Incorrect information in the README file

    [bug] Incorrect information in the README file

    Describe the bug The README file states the OS64COMBINED flag builds a fat lib including iphoneOS and iphoneOS Simulator, but in the toolchain file the statement is completely different.

    To Reproduce

    Expected behavior The documentation is correct

    Environment

    #    OS64COMBINED = Build for arm64 x86_64 iphoneOS. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY)
    
    bug 
    opened by arsdever 2
Releases(4.3.0)
  • 4.3.0(May 20, 2022)

    This version of the toolchain contains lots of bugfixes as well as named languages support (via enable_language() for OBJC and OBJCXX). This should work for most implementations and the default is to enable named language support. If you want the old behaviour, just set the variable NAMED_LANGUAGE_SUPPORT=OFF.

    Source code(tar.gz)
    Source code(zip)
  • 4.2.0(Mar 10, 2021)

    This version includes mostly bugfixes for the macOS builds as well as some other fixes including:

    • CMAKE_FIND_ROOT_PATH is now not being overridden anymore. The toolchain append necessary paths on any existing paths specified by the user. This allows user-specified paths to be searched before the toolchain paths.
    • APPLE_TARGET_TRIPLE property is now being set for manually specified ARCHS as well
    • Excluded some directories from the Catalyst builds since they'd otherwise interfere with the iOS toolchain
    Source code(tar.gz)
    Source code(zip)
  • 4.1.1(Mar 1, 2021)

    This version contains lots of bugfixes as well as the following new features:

    • macOS builds support (more or less just proxying the builds to the host machine)
    • Catalyst support (iOS/iPadOS on macOS)
    • Apple Silicon builds support (requires CMake 3.19.5+)
    • Significant toolchain speedup on Makefile and Ninja generators (possibly more)
    Source code(tar.gz)
    Source code(zip)
  • 3.1.2(Dec 22, 2019)

    Fixes:

    • Lots of formatting and output/prints fixed
    • Fixes a backwards compatibility issue as well that prevented CMake versions older than 3.10 from running correctly
    Source code(tar.gz)
    Source code(zip)
  • 3.1.1(Dec 18, 2019)

  • 3.1.0(Aug 16, 2019)

    Fixes:

    • Minor changes for better third-party compatibility

    Added:

    • New test for building libCurl with combined build support for iOS (arm64 & x86_64).
    Source code(tar.gz)
    Source code(zip)
  • 3.0.2(May 10, 2019)

  • 3.0.1(Apr 8, 2019)

    Fixes:

    • The toolchain have been generalised (removed iOS references in command arguments and variables)
    • Fixes #25 by enforcing 64-bit builds on iOS 10.0+. 32-bit builds have been deprecated officially.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Apr 7, 2019)

    This version comes with the much awaited comined-builds support. That means that CMake now can create FAT-binaries with both device and simultor slices in one go!

    Features:

    • Combined build support. Se the *COMBINED platform options (CMake 3.14+ needed)
    • The Xcode project generator (-G Xcode) now works much better and adheres to most build options set with the toolchain

    Deprecated:

    • IOS_PLATFORM argument have been renamed to PLATFORM to better signal its use. IOS_PLATFORM is now aliased to PLATFORM and thus still works, but will give a deprecation warning

    NOTE! Due to kitware doing an awesome work on CMake, I strongly suggest you all to increase your versions to 3.14+ since the Darwin-based platforms works much better from that version and up ✌

    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Feb 5, 2019)

  • 2.1.4(Nov 18, 2018)

    Removed:

    • The legacy compiler checks that was forcefully set to succeed have been removed, since they no longer are needed in more recent versions of CMake.
    Source code(tar.gz)
    Source code(zip)
  • 2.1.3(Nov 12, 2018)

  • 2.1.2(Nov 1, 2018)

  • 2.1.1(Oct 23, 2018)

  • 2.1.0(Oct 11, 2018)

    Version 2.1.0 adds support for watchOS and contains a few bug-fixes and smaller improvements.

    Added:

    • watchOS support

    Fixes:

    • Will now "self-heal" upon upgrading Xcode version on consequent builds
    • Some flags set was causing third-party libraries to fail tests
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(May 4, 2018)

    This release includes better support for lots of third-party libraries due to better compiler recognition options in the toolchain.

    PSA:

    • This release will in some cases break the compatibility with bitcode enabled projects on simulator builds, due to bitcode not being build on simulator anymore, since it is not needed (or even feasible).

    Fixes:

    • Fixes an issue where the bitness of the platforms could not be determined correctly in some cases.
    • Added ELF as compiler platform, since it was missing before
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Feb 14, 2018)

    News: Version 1.1.0 brings better stability and improved support for newer toolchains.

    Fixes:

    • Fixes an issue where re-running CMake would cause the whole project to be rebuilt.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Dec 13, 2017)

Owner
Alexander Widerberg
Manager of software development @xmreality
Alexander Widerberg
cmake-avr - a cmake toolchain for AVR projects

cmake-avr - a cmake toolchain for AVR projects Testing the example provided The toolchain was created and tested within the following environment: Lin

Matthias Kleemann 163 Dec 5, 2022
CMake toolchain file and other scripts for the Android NDK

android-cmake CMake is great, and so is Android. This is a collection of CMake scripts that may be useful to the Android NDK community. It is based on

Andrey Kamaev 1.2k Jan 7, 2023
CMake toolchain for all Arduino compatible boards

Arduino CMake Toolchain Arduino CMake toolchain is a CMake toolchain for cross-compiling CMake based projects for all Arduino compatible boards (AVR,

Arun 112 Jan 4, 2023
📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Setup-free CMake dependency management CPM.cmake is a CMake script that adds dependency management capabilities to CMake. It's built as a thin wrapper

CPM.cmake 1.6k Jan 9, 2023
CMake checks cache helper modules – for fast CI CMake builds!

cmake-checks-cache Cross platform CMake projects do platform introspection by the means of "Check" macros. Have a look at CMake's How To Write Platfor

Cristian Adam 65 Dec 6, 2022
CMake scripts for painless usage of SuiteSparse+METIS from Visual Studio and the rest of Windows/Linux/OSX IDEs supported by CMake

CMake scripts for painless usage of Tim Davis' SuiteSparse (CHOLMOD,UMFPACK,AMD,LDL,SPQR,...) and METIS from Visual Studio and the rest of Windows/Lin

Jose Luis Blanco-Claraco 395 Dec 24, 2022
cmake-font-lock - Advanced, type aware, highlight support for CMake

cmake-font-lock - Advanced, type aware, highlight support for CMake

Anders Lindgren 39 Oct 2, 2022
Make CMake less painful when trying to write Modern Flexible CMake

Izzy's eXtension Modules IXM is a CMake library for writing Modern flexible CMake. This means: Reducing the amount of CMake written Selecting reasonab

IXM 107 Sep 1, 2022
CMake module to enable code coverage easily and generate coverage reports with CMake targets.

CMake-codecov CMake module to enable code coverage easily and generate coverage reports with CMake targets. Include into your project To use Findcodec

HPC 82 Nov 30, 2022
unmaintained - CMake module to activate certain C++ standard, feature checks and appropriate automated workarounds - basically an improved version of cmake-compile-features

Compatibility This library provides an advanced target_compile_features() and write_compiler_detection_header(). The problem with those is that they a

Jonathan Müller 74 Dec 26, 2022
[CMake] [BSD-2] CMake module to find ICU

FindICU.cmake A CMake module to find International Components for Unicode (ICU) Library Note that CMake, since its version 3.7.0, includes a FindICU m

julp 29 Nov 2, 2022
CMake macro to determine the language of a header file

CMake Determine Header Language CMake macro to determine the language of a header file. Status Travis CI (Ubuntu) AppVeyor (Windows) Coverage Biicode

ポリ平方 POLYSQUARE 4 Dec 7, 2018
C++ Library Manager for Windows, Linux, and MacOS

Vcpkg: Overview 中文总览 Español 한국어 Français Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This tool and ecosystem are constant

Microsoft 17.5k Jan 1, 2023
CMake project for BL602 RISC-V processor

bl602_cmake_base CMake project for BL602 RISC-V processor How to build NOTE : This project uses a pre-compiled version of the Buffalo SDK (bl_iot_sdk)

null 9 Jan 6, 2022
curl cmake module libcurl build with msvc x86

curl-msvc Infomation curl cmake module libcurl build with MSVC10.0 arch (x86 | i386) source from https://github.com/curl/curl tags: curl-7_79_1 Usage

Jason Payne 0 May 16, 2022
NeoWorld is a resampler using the CMake build system

NeoWorld is a resampler using the CMake build system. It's designed for utsu, OpenUTAU, and UTAU.

null 5 Dec 23, 2022
A CMake addon that avoids you writing boilerplate code for resource management.

SHader INJ(I)ector SHINJI (originally SHader INJector) is a CMake addon that avoids you writing boilerplate code for resource management and exposes s

Lorenzo Rutayisire 6 Dec 14, 2022
A CMake starter template using CPM

Cmake Starter About A lightweight Cmake project meant for a binary application (not a shared library), tests with catch2 are configured, CPM is the pa

Matt Williams 1 Jul 14, 2022
Non-intrusive CMake dependency management

cmodule Non-intrusive CMake dependency management. Normally CMake's find_package() looks for packages installed on host system (and compiled for host

scapix.com 14 Sep 29, 2022