From fafb897ff7f6dafaa8fd8c2ece31419029cad239 Mon Sep 17 00:00:00 2001 From: nihui Date: Wed, 3 Apr 2024 11:05:32 +0800 Subject: [PATCH] update ios toolchain, add visionos ci, update watchos, ncnn target ilp32 (#5399) --- .github/workflows/tvos-cpu.yml | 73 ------------- .github/workflows/tvos.yml | 153 +++++++++++++++++++++++++++ .github/workflows/visionos.yml | 153 +++++++++++++++++++++++++++ .github/workflows/watchos-cpu.yml | 91 ---------------- .github/workflows/watchos.yml | 170 ++++++++++++++++++++++++++++++ CMakeLists.txt | 12 ++- README.md | 4 +- cmake/ncnn_add_layer.cmake | 4 +- src/CMakeLists.txt | 4 +- toolchains/ios.toolchain.cmake | 53 +++++++--- 10 files changed, 529 insertions(+), 188 deletions(-) delete mode 100644 .github/workflows/tvos-cpu.yml create mode 100644 .github/workflows/tvos.yml create mode 100644 .github/workflows/visionos.yml delete mode 100644 .github/workflows/watchos-cpu.yml create mode 100644 .github/workflows/watchos.yml diff --git a/.github/workflows/tvos-cpu.yml b/.github/workflows/tvos-cpu.yml deleted file mode 100644 index fcfa7097fd6f..000000000000 --- a/.github/workflows/tvos-cpu.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: tvos-cpu -on: - push: - branches: [master] - paths: - - '.github/workflows/tvos-cpu.yml' - - 'toolchains/ios.toolchain.cmake' - - 'CMakeLists.txt' - - 'cmake/**' - - 'src/*' - - 'src/layer/*' - - 'src/layer/arm/**' - pull_request: - branches: [master] - paths: - - '.github/workflows/tvos-cpu.yml' - - 'toolchains/ios.toolchain.cmake' - - 'CMakeLists.txt' - - 'cmake/**' - - 'src/*' - - 'src/layer/*' - - 'src/layer/arm/**' -concurrency: - group: tvos-cpu-${{ github.ref }} - cancel-in-progress: true -env: - DEVELOPER_DIR: /Applications/Xcode_13.4.1.app/Contents/Developer - TVOS_DEPLOYMENT_TARGET: '9.0' - ENABLE_BITCODE: OFF - ENABLE_ARC: OFF - ENABLE_VISIBILITY: OFF -permissions: - contents: read - -jobs: - tvos: - runs-on: macos-12 - steps: - - uses: actions/checkout@v4 - - - name: build-arm64 - run: | - mkdir build-arm64 && cd build-arm64 - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DPLATFORM=TVOS -DARCHS="arm64" \ - -DDEPLOYMENT_TARGET=$TVOS_DEPLOYMENT_TARGET -DENABLE_BITCODE=$ENABLE_BITCODE -DENABLE_ARC=$ENABLE_ARC -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \ - .. - cmake --build . -j 3 - - tvos-simulator: - runs-on: macos-12 - steps: - - uses: actions/checkout@v4 - - - name: build-x86_64 - run: | - mkdir build-x86_64 && cd build-x86_64 - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DPLATFORM=SIMULATOR_TVOS -DARCHS="x86_64" \ - -DDEPLOYMENT_TARGET=$TVOS_DEPLOYMENT_TARGET -DENABLE_BITCODE=$ENABLE_BITCODE -DENABLE_ARC=$ENABLE_ARC -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \ - .. - cmake --build . -j 3 - - name: build-arm64 - run: | - mkdir build-arm64 && cd build-arm64 - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DPLATFORM=SIMULATORARM64_TVOS -DARCHS="arm64" \ - -DDEPLOYMENT_TARGET=$TVOS_DEPLOYMENT_TARGET -DENABLE_BITCODE=$ENABLE_BITCODE -DENABLE_ARC=$ENABLE_ARC -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \ - .. - cmake --build . -j 3 diff --git a/.github/workflows/tvos.yml b/.github/workflows/tvos.yml new file mode 100644 index 000000000000..88bc03734d17 --- /dev/null +++ b/.github/workflows/tvos.yml @@ -0,0 +1,153 @@ +name: tvos +on: + push: + branches: [master] + paths: + - '.github/workflows/tvos.yml' + - 'toolchains/ios.toolchain.cmake' + - 'CMakeLists.txt' + - 'cmake/**' + - 'src/*' + - 'src/layer/*' + - 'src/layer/arm/**' + - 'src/layer/x86/**' + pull_request: + branches: [master] + paths: + - '.github/workflows/tvos.yml' + - 'toolchains/ios.toolchain.cmake' + - 'CMakeLists.txt' + - 'cmake/**' + - 'src/*' + - 'src/layer/*' + - 'src/layer/arm/**' + - 'src/layer/x86/**' +concurrency: + group: tvos-${{ github.ref }} + cancel-in-progress: true +env: + DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + TVOS_DEPLOYMENT_TARGET: '9.0' + ENABLE_BITCODE: OFF + ENABLE_ARC: OFF + ENABLE_VISIBILITY: OFF +permissions: + contents: read + +jobs: + build: + runs-on: macos-13 + env: + OPENMP_VERSION: '18.1.2' + OPENMP_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$TVOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DPERL_EXECUTABLE=/usr/local/bin/perl \ + -DLIBOMP_ENABLE_SHARED=OFF \ + -DLIBOMP_OMPT_SUPPORT=OFF \ + -DLIBOMP_USE_HWLOC=OFF \ + + NCNN_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$TVOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOpenMP_C_FLAGS="-Xclang -fopenmp" -DOpenMP_CXX_FLAGS="-Xclang -fopenmp" \ + -DOpenMP_C_LIB_NAMES="libomp" -DOpenMP_CXX_LIB_NAMES="libomp" \ + -DOpenMP_libomp_LIBRARY="libomp.a" \ + + steps: + - uses: actions/checkout@v4 + + - name: cache-openmp + id: cache-openmp + uses: actions/cache@v4 + with: + path: openmp-install + key: openmp-tvos-install-20240402 + - name: openmp + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.OPENMP_VERSION }}/cmake-${{ env.OPENMP_VERSION }}.src.tar.xz + tar -xf cmake-${{ env.OPENMP_VERSION }}.src.tar.xz + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.OPENMP_VERSION }}/openmp-${{ env.OPENMP_VERSION }}.src.tar.xz + tar -xf openmp-${{ env.OPENMP_VERSION }}.src.tar.xz + mv cmake-${{ env.OPENMP_VERSION }}.src/Modules/* openmp-${{ env.OPENMP_VERSION }}.src/cmake/ + cd openmp-${{ env.OPENMP_VERSION }}.src + wget https://github.com/nihui/llvm-project/commit/ef8c35bcf5d9cfdb0764ffde6a63c04ec715bc37.patch + patch -p2 -i ef8c35bcf5d9cfdb0764ffde6a63c04ec715bc37.patch + wget https://github.com/nihui/llvm-project/commit/5c12711f9a21f41bea70566bf15a4026804d6b20.patch + patch -p2 -i 5c12711f9a21f41bea70566bf15a4026804d6b20.patch + - name: openmp-arm64 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-arm64 && cd build-arm64 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=TVOS -DARCHS="arm64" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-simulator-x86_64 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-simulator-x86_64 && cd build-simulator-x86_64 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_TVOS -DARCHS="x86_64" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-simulator-arm64 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-simulator-arm64 && cd build-simulator-arm64 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_TVOS -DARCHS="arm64" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-merge-fat-library + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + mkdir -p $GITHUB_WORKSPACE/openmp-install + mkdir -p $GITHUB_WORKSPACE/openmp-install/tvos + mkdir -p $GITHUB_WORKSPACE/openmp-install/tvos-simulator + + cp -a openmp-${{ env.OPENMP_VERSION }}.src/build-arm64/install/include $GITHUB_WORKSPACE/openmp-install/tvos + mkdir -p $GITHUB_WORKSPACE/openmp-install/tvos/lib + cp openmp-${{ env.OPENMP_VERSION }}.src/build-arm64/install/lib/libomp.a $GITHUB_WORKSPACE/openmp-install/tvos/lib/libomp.a + + cp -a openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-x86_64/install/include $GITHUB_WORKSPACE/openmp-install/tvos-simulator + mkdir -p $GITHUB_WORKSPACE/openmp-install/tvos-simulator/lib + lipo -create \ + openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-x86_64/install/lib/libomp.a \ + openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-arm64/install/lib/libomp.a \ + -o $GITHUB_WORKSPACE/openmp-install/tvos-simulator/lib/libomp.a + + - name: install-openmp + run: | + sudo cp $GITHUB_WORKSPACE/openmp-install/tvos/include/* $DEVELOPER_DIR/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include + sudo cp $GITHUB_WORKSPACE/openmp-install/tvos/lib/libomp.a $DEVELOPER_DIR/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/lib + + sudo cp $GITHUB_WORKSPACE/openmp-install/tvos-simulator/include/* $DEVELOPER_DIR/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include + sudo cp $GITHUB_WORKSPACE/openmp-install/tvos-simulator/lib/libomp.a $DEVELOPER_DIR/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/lib + + - name: arm64 + run: | + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=TVOS -DARCHS="arm64" .. + cmake --build . -j 4 + - name: simulator-x86_64 + run: | + mkdir build-simulator-x86_64 && cd build-simulator-x86_64 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_TVOS -DARCHS="x86_64" .. + cmake --build . -j 4 + - name: simulator-arm64 + run: | + mkdir build-simulator-arm64 && cd build-simulator-arm64 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=SIMULATORARM64_TVOS -DARCHS="arm64" .. + cmake --build . -j 4 diff --git a/.github/workflows/visionos.yml b/.github/workflows/visionos.yml new file mode 100644 index 000000000000..c1da0d9a948a --- /dev/null +++ b/.github/workflows/visionos.yml @@ -0,0 +1,153 @@ +name: visionos +on: + push: + branches: [master] + paths: + - '.github/workflows/visionos.yml' + - 'toolchains/ios.toolchain.cmake' + - 'CMakeLists.txt' + - 'cmake/**' + - 'src/*' + - 'src/layer/*' + - 'src/layer/arm/**' + - 'src/layer/x86/**' + pull_request: + branches: [master] + paths: + - '.github/workflows/visionos.yml' + - 'toolchains/ios.toolchain.cmake' + - 'CMakeLists.txt' + - 'cmake/**' + - 'src/*' + - 'src/layer/*' + - 'src/layer/arm/**' + - 'src/layer/x86/**' +concurrency: + group: visionos-${{ github.ref }} + cancel-in-progress: true +env: + DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + VISIONOS_DEPLOYMENT_TARGET: '1.0' + ENABLE_BITCODE: OFF + ENABLE_ARC: OFF + ENABLE_VISIBILITY: OFF +permissions: + contents: read + +jobs: + build: + runs-on: macos-13 + env: + OPENMP_VERSION: '18.1.2' + OPENMP_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$VISIONOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DPERL_EXECUTABLE=/usr/local/bin/perl \ + -DLIBOMP_ENABLE_SHARED=OFF \ + -DLIBOMP_OMPT_SUPPORT=OFF \ + -DLIBOMP_USE_HWLOC=OFF \ + + NCNN_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$VISIONOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOpenMP_C_FLAGS="-Xclang -fopenmp" -DOpenMP_CXX_FLAGS="-Xclang -fopenmp" \ + -DOpenMP_C_LIB_NAMES="libomp" -DOpenMP_CXX_LIB_NAMES="libomp" \ + -DOpenMP_libomp_LIBRARY="libomp.a" \ + + steps: + - uses: actions/checkout@v4 + + - name: cache-openmp + id: cache-openmp + uses: actions/cache@v4 + with: + path: openmp-install + key: openmp-visionos-install-20240402 + - name: openmp + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.OPENMP_VERSION }}/cmake-${{ env.OPENMP_VERSION }}.src.tar.xz + tar -xf cmake-${{ env.OPENMP_VERSION }}.src.tar.xz + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.OPENMP_VERSION }}/openmp-${{ env.OPENMP_VERSION }}.src.tar.xz + tar -xf openmp-${{ env.OPENMP_VERSION }}.src.tar.xz + mv cmake-${{ env.OPENMP_VERSION }}.src/Modules/* openmp-${{ env.OPENMP_VERSION }}.src/cmake/ + cd openmp-${{ env.OPENMP_VERSION }}.src + wget https://github.com/nihui/llvm-project/commit/ef8c35bcf5d9cfdb0764ffde6a63c04ec715bc37.patch + patch -p2 -i ef8c35bcf5d9cfdb0764ffde6a63c04ec715bc37.patch + wget https://github.com/nihui/llvm-project/commit/5c12711f9a21f41bea70566bf15a4026804d6b20.patch + patch -p2 -i 5c12711f9a21f41bea70566bf15a4026804d6b20.patch + - name: openmp-arm64 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-arm64 && cd build-arm64 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=VISIONOS -DARCHS="arm64" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-simulator-x86_64 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-simulator-x86_64 && cd build-simulator-x86_64 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_VISIONOS -DARCHS="x86_64" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-simulator-arm64 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-simulator-arm64 && cd build-simulator-arm64 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_VISIONOS -DARCHS="arm64" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-merge-fat-library + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + mkdir -p $GITHUB_WORKSPACE/openmp-install + mkdir -p $GITHUB_WORKSPACE/openmp-install/visionos + mkdir -p $GITHUB_WORKSPACE/openmp-install/visionos-simulator + + cp -a openmp-${{ env.OPENMP_VERSION }}.src/build-arm64/install/include $GITHUB_WORKSPACE/openmp-install/visionos + mkdir -p $GITHUB_WORKSPACE/openmp-install/visionos/lib + cp openmp-${{ env.OPENMP_VERSION }}.src/build-arm64/install/lib/libomp.a $GITHUB_WORKSPACE/openmp-install/visionos/lib/libomp.a + + cp -a openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-x86_64/install/include $GITHUB_WORKSPACE/openmp-install/visionos-simulator + mkdir -p $GITHUB_WORKSPACE/openmp-install/visionos-simulator/lib + lipo -create \ + openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-x86_64/install/lib/libomp.a \ + openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-arm64/install/lib/libomp.a \ + -o $GITHUB_WORKSPACE/openmp-install/visionos-simulator/lib/libomp.a + + - name: install-openmp + run: | + sudo cp $GITHUB_WORKSPACE/openmp-install/visionos/include/* $DEVELOPER_DIR/Platforms/XROS.platform/Developer/SDKs/XROS.sdk/usr/include + sudo cp $GITHUB_WORKSPACE/openmp-install/visionos/lib/libomp.a $DEVELOPER_DIR/Platforms/XROS.platform/Developer/SDKs/XROS.sdk/usr/lib + + sudo cp $GITHUB_WORKSPACE/openmp-install/visionos-simulator/include/* $DEVELOPER_DIR/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator.sdk/usr/include + sudo cp $GITHUB_WORKSPACE/openmp-install/visionos-simulator/lib/libomp.a $DEVELOPER_DIR/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator.sdk/usr/lib + + - name: arm64 + run: | + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=VISIONOS -DARCHS="arm64" .. + cmake --build . -j 4 + - name: simulator-x86_64 + run: | + mkdir build-simulator-x86_64 && cd build-simulator-x86_64 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_VISIONOS -DARCHS="x86_64" .. + cmake --build . -j 4 + - name: simulator-arm64 + run: | + mkdir build-simulator-arm64 && cd build-simulator-arm64 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_VISIONOS -DARCHS="arm64" .. + cmake --build . -j 4 diff --git a/.github/workflows/watchos-cpu.yml b/.github/workflows/watchos-cpu.yml deleted file mode 100644 index adcea8103750..000000000000 --- a/.github/workflows/watchos-cpu.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: watchos-cpu -on: - push: - branches: [master] - paths: - - '.github/workflows/watchos-cpu.yml' - - 'toolchains/ios.toolchain.cmake' - - 'CMakeLists.txt' - - 'cmake/**' - - 'src/*' - - 'src/layer/*' - - 'src/layer/arm/**' - pull_request: - branches: [master] - paths: - - '.github/workflows/watchos-cpu.yml' - - 'toolchains/ios.toolchain.cmake' - - 'CMakeLists.txt' - - 'cmake/**' - - 'src/*' - - 'src/layer/*' - - 'src/layer/arm/**' -concurrency: - group: watchos-cpu-${{ github.ref }} - cancel-in-progress: true -env: - DEVELOPER_DIR: /Applications/Xcode_13.4.1.app/Contents/Developer - WATCHOS_DEPLOYMENT_TARGET: '2.0' - ENABLE_BITCODE: OFF - ENABLE_ARC: OFF - ENABLE_VISIBILITY: OFF -permissions: - contents: read - -jobs: - watchos: - runs-on: macos-12 - steps: - - uses: actions/checkout@v4 - - - name: build-armv7k - run: | - mkdir build-armv7k && cd build-armv7k - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DPLATFORM=WATCHOS -DARCHS="armv7k" \ - -DDEPLOYMENT_TARGET=$WATCHOS_DEPLOYMENT_TARGET -DENABLE_BITCODE=$ENABLE_BITCODE -DENABLE_ARC=$ENABLE_ARC -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \ - .. - cmake --build . -j 3 - - name: build-arm64_32 - run: | - mkdir build-arm64_32 && cd build-arm64_32 - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DPLATFORM=WATCHOS -DARCHS="arm64_32" \ - -DDEPLOYMENT_TARGET=$WATCHOS_DEPLOYMENT_TARGET -DENABLE_BITCODE=$ENABLE_BITCODE -DENABLE_ARC=$ENABLE_ARC -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \ - .. - cmake --build . -j 3 - - watchos-simulator: - runs-on: macos-12 - steps: - - uses: actions/checkout@v4 - - - name: build-i386 - run: | - mkdir build-i386 && cd build-i386 - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DPLATFORM=SIMULATOR_WATCHOS -DARCHS="i386" \ - -DDEPLOYMENT_TARGET=$WATCHOS_DEPLOYMENT_TARGET -DENABLE_BITCODE=$ENABLE_BITCODE -DENABLE_ARC=$ENABLE_ARC -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \ - .. - cmake --build . -j 3 - - name: build-x86_64 - run: | - mkdir build-x86_64 && cd build-x86_64 - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DPLATFORM=SIMULATOR_WATCHOS -DARCHS="x86_64" \ - -DDEPLOYMENT_TARGET=$WATCHOS_DEPLOYMENT_TARGET -DENABLE_BITCODE=$ENABLE_BITCODE -DENABLE_ARC=$ENABLE_ARC -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \ - .. - cmake --build . -j 3 - - name: build-arm64 - run: | - mkdir build-arm64 && cd build-arm64 - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DPLATFORM=SIMULATOR_WATCHOS -DARCHS="arm64" \ - -DDEPLOYMENT_TARGET=$WATCHOS_DEPLOYMENT_TARGET -DENABLE_BITCODE=$ENABLE_BITCODE -DENABLE_ARC=$ENABLE_ARC -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \ - .. - cmake --build . -j 3 diff --git a/.github/workflows/watchos.yml b/.github/workflows/watchos.yml new file mode 100644 index 000000000000..042c6c3ed540 --- /dev/null +++ b/.github/workflows/watchos.yml @@ -0,0 +1,170 @@ +name: watchos +on: + push: + branches: [master] + paths: + - '.github/workflows/watchos.yml' + - 'toolchains/ios.toolchain.cmake' + - 'CMakeLists.txt' + - 'cmake/**' + - 'src/*' + - 'src/layer/*' + - 'src/layer/arm/**' + - 'src/layer/x86/**' + pull_request: + branches: [master] + paths: + - '.github/workflows/watchos.yml' + - 'toolchains/ios.toolchain.cmake' + - 'CMakeLists.txt' + - 'cmake/**' + - 'src/*' + - 'src/layer/*' + - 'src/layer/arm/**' + - 'src/layer/x86/**' +concurrency: + group: watchos-${{ github.ref }} + cancel-in-progress: true +env: + DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + WATCHOS_DEPLOYMENT_TARGET: '6.0' + ENABLE_BITCODE: OFF + ENABLE_ARC: OFF + ENABLE_VISIBILITY: OFF +permissions: + contents: read + +jobs: + build: + runs-on: macos-13 + env: + OPENMP_VERSION: '18.1.2' + OPENMP_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$WATCHOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DPERL_EXECUTABLE=/usr/local/bin/perl \ + -DLIBOMP_ENABLE_SHARED=OFF \ + -DLIBOMP_OMPT_SUPPORT=OFF \ + -DLIBOMP_USE_HWLOC=OFF \ + + NCNN_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$WATCHOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOpenMP_C_FLAGS="-Xclang -fopenmp" -DOpenMP_CXX_FLAGS="-Xclang -fopenmp" \ + -DOpenMP_C_LIB_NAMES="libomp" -DOpenMP_CXX_LIB_NAMES="libomp" \ + -DOpenMP_libomp_LIBRARY="libomp.a" \ + + steps: + - uses: actions/checkout@v4 + + - name: cache-openmp + id: cache-openmp + uses: actions/cache@v4 + with: + path: openmp-install + key: openmp-watchos-install-20240402 + - name: openmp + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.OPENMP_VERSION }}/cmake-${{ env.OPENMP_VERSION }}.src.tar.xz + tar -xf cmake-${{ env.OPENMP_VERSION }}.src.tar.xz + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.OPENMP_VERSION }}/openmp-${{ env.OPENMP_VERSION }}.src.tar.xz + tar -xf openmp-${{ env.OPENMP_VERSION }}.src.tar.xz + mv cmake-${{ env.OPENMP_VERSION }}.src/Modules/* openmp-${{ env.OPENMP_VERSION }}.src/cmake/ + cd openmp-${{ env.OPENMP_VERSION }}.src + wget https://github.com/nihui/llvm-project/commit/ef8c35bcf5d9cfdb0764ffde6a63c04ec715bc37.patch + patch -p2 -i ef8c35bcf5d9cfdb0764ffde6a63c04ec715bc37.patch + wget https://github.com/nihui/llvm-project/commit/5c12711f9a21f41bea70566bf15a4026804d6b20.patch + patch -p2 -i 5c12711f9a21f41bea70566bf15a4026804d6b20.patch + - name: openmp-armv7k + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-armv7k && cd build-armv7k + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=WATCHOS -DARCHS="armv7k" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-arm64_32 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-arm64_32 && cd build-arm64_32 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=WATCHOS -DARCHS="arm64_32" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-simulator-x86_64 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-simulator-x86_64 && cd build-simulator-x86_64 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_WATCHOS -DARCHS="x86_64" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-simulator-arm64 + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + cd openmp-${{ env.OPENMP_VERSION }}.src + mkdir -p build-simulator-arm64 && cd build-simulator-arm64 + cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_WATCHOS -DARCHS="arm64" .. + cmake --build . -j 4 + cmake --build . --target install + - name: openmp-merge-fat-library + if: steps.cache-openmp.outputs.cache-hit != 'true' + run: | + mkdir -p $GITHUB_WORKSPACE/openmp-install + mkdir -p $GITHUB_WORKSPACE/openmp-install/watchos + mkdir -p $GITHUB_WORKSPACE/openmp-install/watchos-simulator + + cp -a openmp-${{ env.OPENMP_VERSION }}.src/build-arm64_32/install/include $GITHUB_WORKSPACE/openmp-install/watchos + mkdir -p $GITHUB_WORKSPACE/openmp-install/watchos/lib + lipo -create \ + openmp-${{ env.OPENMP_VERSION }}.src/build-armv7k/install/lib/libomp.a \ + openmp-${{ env.OPENMP_VERSION }}.src/build-arm64_32/install/lib/libomp.a \ + -o $GITHUB_WORKSPACE/openmp-install/watchos/lib/libomp.a + + cp -a openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-x86_64/install/include $GITHUB_WORKSPACE/openmp-install/watchos-simulator + mkdir -p $GITHUB_WORKSPACE/openmp-install/watchos-simulator/lib + lipo -create \ + openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-x86_64/install/lib/libomp.a \ + openmp-${{ env.OPENMP_VERSION }}.src/build-simulator-arm64/install/lib/libomp.a \ + -o $GITHUB_WORKSPACE/openmp-install/watchos-simulator/lib/libomp.a + + - name: install-openmp + run: | + sudo cp $GITHUB_WORKSPACE/openmp-install/watchos/include/* $DEVELOPER_DIR/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include + sudo cp $GITHUB_WORKSPACE/openmp-install/watchos/lib/libomp.a $DEVELOPER_DIR/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/lib + + sudo cp $GITHUB_WORKSPACE/openmp-install/watchos-simulator/include/* $DEVELOPER_DIR/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include + sudo cp $GITHUB_WORKSPACE/openmp-install/watchos-simulator/lib/libomp.a $DEVELOPER_DIR/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/lib + + - name: armv7k + run: | + mkdir build-armv7k && cd build-armv7k + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=WATCHOS -DARCHS="armv7k" .. + cmake --build . -j 4 + - name: arm64_32 + run: | + mkdir build-arm64_32 && cd build-arm64_32 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=WATCHOS -DARCHS="arm64_32" .. + cmake --build . -j 4 + + - name: simulator-x86_64 + run: | + mkdir build-simulator-x86_64 && cd build-simulator-x86_64 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_WATCHOS -DARCHS="x86_64" .. + cmake --build . -j 4 + - name: simulator-arm64 + run: | + mkdir build-simulator-arm64 && cd build-simulator-arm64 + cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DPLATFORM=SIMULATOR_WATCHOS -DARCHS="arm64" .. + cmake --build . -j 4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 785e2cd39264..a67ab6afb5e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,7 +148,11 @@ if((IOS AND CMAKE_OSX_ARCHITECTURES MATCHES "arm") OR ((CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) AND (${CMAKE_GENERATOR_PLATFORM} MATCHES "^(arm|arm64)"))) set(NCNN_TARGET_ARCH arm) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) + if(APPLE AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64_32") + set(NCNN_TARGET_ILP32 TRUE) + endif() + + if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT NCNN_TARGET_ILP32) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) set(CMAKE_REQUIRED_FLAGS "/arch:VFPv4") check_cxx_source_compiles("#include \nint main() { float32x4_t _a; float16x4_t _s = vcvt_f16_f32(_a); return 0; }" NCNN_COMPILER_SUPPORT_ARM_VFPV4) @@ -173,7 +177,7 @@ if((IOS AND CMAKE_OSX_ARCHITECTURES MATCHES "arm") endif() endif() - if(CMAKE_SIZEOF_VOID_P EQUAL 8) + if(CMAKE_SIZEOF_VOID_P EQUAL 8 OR NCNN_TARGET_ILP32) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) set(CMAKE_REQUIRED_FLAGS "/arch:armv8.0") check_cxx_source_compiles("#include \nint main() { float32x4_t _a; float16x4_t _s = vcvt_f16_f32(_a); return 0; }" NCNN_COMPILER_SUPPORT_ARM_VFPV4) @@ -560,7 +564,9 @@ else() endif() endif() -if(CMAKE_SIZEOF_VOID_P EQUAL 8) +if(NCNN_TARGET_ILP32) + message(STATUS "Target arch: ${NCNN_TARGET_ARCH} 64bit ilp32") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "Target arch: ${NCNN_TARGET_ARCH} 64bit") else() message(STATUS "Target arch: ${NCNN_TARGET_ARCH} 32bit") diff --git a/README.md b/README.md index a4b2876a5e24..be4f7a9b60e1 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ https://github.com/Tencent/ncnn/releases/latest - [](https://github.com/Tencent/ncnn/actions?query=workflow%3Awatchos-cpu) + [](https://github.com/Tencent/ncnn/actions?query=workflow%3Awatchos) @@ -258,7 +258,7 @@ https://github.com/Tencent/ncnn/releases/latest - [](https://github.com/Tencent/ncnn/actions?query=workflow%3Atvos-cpu) + [](https://github.com/Tencent/ncnn/actions?query=workflow%3Atvos) diff --git a/cmake/ncnn_add_layer.cmake b/cmake/ncnn_add_layer.cmake index 4eeedb010c7d..a41c52e4ed22 100644 --- a/cmake/ncnn_add_layer.cmake +++ b/cmake/ncnn_add_layer.cmake @@ -199,7 +199,7 @@ macro(ncnn_add_layer class) endif() endif() - if(NCNN_TARGET_ARCH STREQUAL "arm" AND CMAKE_SIZEOF_VOID_P EQUAL 4) + if(NCNN_TARGET_ARCH STREQUAL "arm" AND (CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT NCNN_TARGET_ILP32)) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) if(NCNN_VFPV4) ncnn_add_arch_opt_source(${class} vfpv4 "/arch:VFPv4 /D__ARM_FP=0x0E") @@ -215,7 +215,7 @@ macro(ncnn_add_layer class) endif() endif() - if(NCNN_TARGET_ARCH STREQUAL "arm" AND CMAKE_SIZEOF_VOID_P EQUAL 8) + if(NCNN_TARGET_ARCH STREQUAL "arm" AND (CMAKE_SIZEOF_VOID_P EQUAL 8 OR NCNN_TARGET_ILP32)) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) if(NCNN_VFPV4) ncnn_add_arch_opt_source(${class} vfpv4 " ") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ba035b94226..d7dfe19c26e1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -470,7 +470,7 @@ if(NCNN_TARGET_ARCH STREQUAL "x86") endif() endif() -if(NCNN_TARGET_ARCH STREQUAL "arm" AND CMAKE_SIZEOF_VOID_P EQUAL 4) +if(NCNN_TARGET_ARCH STREQUAL "arm" AND (CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT NCNN_TARGET_ILP32)) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) # always enable neon for msvc arm target_compile_options(ncnn PRIVATE /D__arm__ /D__ARM_NEON) @@ -493,7 +493,7 @@ if(NCNN_TARGET_ARCH STREQUAL "arm" AND CMAKE_SIZEOF_VOID_P EQUAL 4) endif() endif() -if(NCNN_TARGET_ARCH STREQUAL "arm" AND CMAKE_SIZEOF_VOID_P EQUAL 8) +if(NCNN_TARGET_ARCH STREQUAL "arm" AND (CMAKE_SIZEOF_VOID_P EQUAL 8 OR NCNN_TARGET_ILP32)) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) # always enable neon and vfpv4 for msvc arm64 target_compile_options(ncnn PRIVATE /D__arm__ /D__aarch64__ /D__ARM_NEON /D__ARM_FP=0x0E) diff --git a/toolchains/ios.toolchain.cmake b/toolchains/ios.toolchain.cmake index 44a6fa5abee6..379014166243 100644 --- a/toolchains/ios.toolchain.cmake +++ b/toolchains/ios.toolchain.cmake @@ -70,6 +70,7 @@ # WATCHOS = Build for armv7k arm64_32 for watchOS. # WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS + watchOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) # SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator. +# SIMULATORARM64_WATCHOS = Build for arm64 for watchOS Simulator. # MAC = Build for x86_64 macOS. # MAC_ARM64 = Build for Apple Silicon macOS. # MAC_UNIVERSAL = Combined build for x86_64 and Apple Silicon on macOS. @@ -87,7 +88,7 @@ # CMAKE_OSX_SYSROOT, but can also be manually specified (although this should # not be required). # -# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 2.0 on watchOS and 9.0 on tvOS+iOS +# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 6.0 on watchOS, 13.0 on tvOS+iOS/iPadOS, 11.0 on macOS, 1.0 on visionOS # # NAMED_LANGUAGE_SUPPORT: # ON (default) = Will require "enable_language(OBJC) and/or enable_language(OBJCXX)" for full OBJC|OBJCXX support @@ -113,6 +114,7 @@ # SIMULATORARM64_TVOS = arm64 # WATCHOS = armv7k arm64_32 (if applicable) # SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated) +# SIMULATORARM64_WATCHOS = arm64 # MAC = x86_64 # MAC_ARM64 = arm64 # MAC_UNIVERSAL = x86_64 arm64 @@ -158,7 +160,7 @@ set(ENV{_IOS_TOOLCHAIN_HAS_RUN} true) list(APPEND _supported_platforms "OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64" "SIMULATOR64COMBINED" "TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS" "SIMULATORARM64_TVOS" - "WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" + "WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS" "MAC" "MAC_ARM64" "MAC_UNIVERSAL" "VISIONOS" "SIMULATOR_VISIONOS" "SIMULATOR64_VISIONOS" "MAC_CATALYST" "MAC_CATALYST_ARM64") @@ -257,10 +259,10 @@ set(NAMED_LANGUAGE_SUPPORT_INT ${NAMED_LANGUAGE_SUPPORT} CACHE BOOL if(NOT DEFINED DEPLOYMENT_TARGET) if (PLATFORM MATCHES "WATCHOS") # Unless specified, SDK version 4.0 is used by default as minimum target version (watchOS). - set(DEPLOYMENT_TARGET "4.0") + set(DEPLOYMENT_TARGET "6.0") elseif(PLATFORM STREQUAL "MAC") # Unless specified, SDK version 10.13 (High Sierra) is used by default as the minimum target version (macos). - set(DEPLOYMENT_TARGET "10.13") + set(DEPLOYMENT_TARGET "11.0") elseif(PLATFORM STREQUAL "VISIONOS" OR PLATFORM STREQUAL "SIMULATOR_VISIONOS" OR PLATFORM STREQUAL "SIMULATOR64_VISIONOS") # Unless specified, SDK version 1.0 is used by default as minimum target version (visionOS). set(DEPLOYMENT_TARGET "1.0") @@ -275,7 +277,7 @@ if(NOT DEFINED DEPLOYMENT_TARGET) set(DEPLOYMENT_TARGET "13.1") else() # Unless specified, SDK version 11.0 is used by default as the minimum target version (iOS, tvOS). - set(DEPLOYMENT_TARGET "11.0") + set(DEPLOYMENT_TARGET "13.0") endif() message(STATUS "[DEFAULTS] Using the default min-version since DEPLOYMENT_TARGET not provided!") elseif(DEFINED DEPLOYMENT_TARGET AND PLATFORM MATCHES "^MAC_CATALYST" AND ${DEPLOYMENT_TARGET} VERSION_LESS "13.1") @@ -481,6 +483,14 @@ elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") else() set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator) endif() +elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_WATCHOS") + set(SDK_NAME watchsimulator) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT arm64-apple-watchos${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator) + endif() elseif(PLATFORM_INT STREQUAL "SIMULATOR64_VISIONOS") set(SDK_NAME xrsimulator) if(NOT ARCHS) @@ -761,6 +771,7 @@ endif() set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_SHARED_LIBRARY_PREFIX "lib") set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") +set(CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES ".tbd" ".so") set(CMAKE_SHARED_MODULE_PREFIX "lib") set(CMAKE_SHARED_MODULE_SUFFIX ".so") set(CMAKE_C_COMPILER_ABI ELF) @@ -816,6 +827,9 @@ elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_TVOS") elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") set(SDK_NAME_VERSION_FLAGS "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_WATCHOS") + set(SDK_NAME_VERSION_FLAGS + "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") elseif(PLATFORM_INT STREQUAL "MAC") set(SDK_NAME_VERSION_FLAGS "-mmacosx-version-min=${DEPLOYMENT_TARGET}") @@ -826,7 +840,7 @@ elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_TVOS") endif() elseif(NOT PLATFORM_INT MATCHES "^MAC_CATALYST") # Newer versions of CMake sets the version min flags correctly, skip this for Mac Catalyst targets - set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}) + set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE INTERNAL "Minimum OS X deployment version") endif() if(DEFINED APPLE_TARGET_TRIPLE_INT) @@ -887,35 +901,44 @@ endif() if(CMAKE_GENERATOR MATCHES "Xcode") message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as the generator. Modifying the Xcode build-settings directly instead.") else() - set(CMAKE_C_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${OBJC_LEGACY_VARS} ${BITCODE} ${VISIBILITY} ${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${OBJC_LEGACY_VARS} ${BITCODE} ${VISIBILITY} ${CMAKE_C_FLAGS}" CACHE INTERNAL + "Flags used by the compiler during all C build types.") set(CMAKE_C_FLAGS_DEBUG "-O0 -g ${CMAKE_C_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_C_FLAGS_MINSIZEREL}") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_C_FLAGS_RELWITHDEBINFO}") set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_C_FLAGS_RELEASE}") - set(CMAKE_CXX_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${OBJC_LEGACY_VARS} ${BITCODE} ${VISIBILITY} ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${OBJC_LEGACY_VARS} ${BITCODE} ${VISIBILITY} ${CMAKE_CXX_FLAGS}" CACHE INTERNAL + "Flags used by the compiler during all CXX build types.") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g ${CMAKE_CXX_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_CXX_FLAGS_MINSIZEREL}") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_CXX_FLAGS_RELEASE}") if(NAMED_LANGUAGE_SUPPORT_INT) - set(CMAKE_OBJC_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} ${FOBJC_ARC} ${OBJC_VARS} ${CMAKE_OBJC_FLAGS}") + set(CMAKE_OBJC_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} ${FOBJC_ARC} ${OBJC_VARS} ${CMAKE_OBJC_FLAGS}" CACHE INTERNAL + "Flags used by the compiler during all OBJC build types.") set(CMAKE_OBJC_FLAGS_DEBUG "-O0 -g ${CMAKE_OBJC_FLAGS_DEBUG}") set(CMAKE_OBJC_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_OBJC_FLAGS_MINSIZEREL}") set(CMAKE_OBJC_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_OBJC_FLAGS_RELWITHDEBINFO}") set(CMAKE_OBJC_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_OBJC_FLAGS_RELEASE}") - set(CMAKE_OBJCXX_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} ${FOBJC_ARC} ${OBJC_VARS} ${CMAKE_OBJCXX_FLAGS}") + set(CMAKE_OBJCXX_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} ${FOBJC_ARC} ${OBJC_VARS} ${CMAKE_OBJCXX_FLAGS}" CACHE INTERNAL + "Flags used by the compiler during all OBJCXX build types.") set(CMAKE_OBJCXX_FLAGS_DEBUG "-O0 -g ${CMAKE_OBJCXX_FLAGS_DEBUG}") set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_OBJCXX_FLAGS_MINSIZEREL}") set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO}") set(CMAKE_OBJCXX_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_OBJCXX_FLAGS_RELEASE}") endif() - set(CMAKE_C_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") - set(CMAKE_CXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") + set(CMAKE_C_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}" CACHE INTERNAL + "Flags used by the compiler for all C link types.") + set(CMAKE_CXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}" CACHE INTERNAL + "Flags used by the compiler for all CXX link types.") if(NAMED_LANGUAGE_SUPPORT_INT) - set(CMAKE_OBJC_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_OBJC_LINK_FLAGS}") - set(CMAKE_OBJCXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_OBJCXX_LINK_FLAGS}") + set(CMAKE_OBJC_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_OBJC_LINK_FLAGS}" CACHE INTERNAL + "Flags used by the compiler for all OBJC link types.") + set(CMAKE_OBJCXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_OBJCXX_LINK_FLAGS}" CACHE INTERNAL + "Flags used by the compiler for all OBJCXX link types.") endif() - set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -arch ${CMAKE_OSX_ARCHITECTURES} ${APPLE_TARGET_TRIPLE_FLAG}") + set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -arch ${CMAKE_OSX_ARCHITECTURES} ${APPLE_TARGET_TRIPLE_FLAG}" CACHE INTERNAL + "Flags used by the compiler for all ASM build types.") endif() ## Print status messages to inform of the current state