From 6a719f0cb1afc8ddc367194d7e009bba08e55162 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:52:43 +0800 Subject: [PATCH] fix compile for android --- .gitea/workflows/android.yml | 34 ++++++---------------------------- CMakeLists.txt | 6 ++++-- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/.gitea/workflows/android.yml b/.gitea/workflows/android.yml index c958736..955a03b 100644 --- a/.gitea/workflows/android.yml +++ b/.gitea/workflows/android.yml @@ -23,6 +23,9 @@ concurrency: jobs: build: runs-on: ubuntu-20.04 + strategy: + matrix: + build_arch: ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"] env: TILE_CMAKE_OPTIONS: | -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ @@ -31,7 +34,6 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DNCNN_VULKAN=ON \ - steps: - uses: actions/checkout@v4 with: @@ -41,32 +43,8 @@ jobs: apt-get update -y apt-get install -y ninja-build - - name: armeabi-v7a + - name: ${{matrix.build_arch}} run: | - mkdir build-armeabi-v7a && cd build-armeabi-v7a - cmake -GNinja .. ${{ env.TILE_CMAKE_OPTIONS}} -DCMAKE_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON + mkdir build && cd build + cmake -GNinja .. ${{ env.TILE_CMAKE_OPTIONS}} -DCMAKE_ABI="${{matrix.build_arch}}" -DANDROID_ARM_NEON=ON cmake --build . -j $(nproc) - - - - name: arm64-v8a - run: | - mkdir build-arm64-v8a && cd build-arm64-v8a - cmake -GNinja .. ${{ env.TILE_CMAKE_OPTIONS}} -DCMAKE_ABI="arm64-v8a" - cmake --build . -j $(nproc) - - - name: x86 - run: | - mkdir build-x86 && cd build-x86 - cmake -GNinja .. ${{ env.TILE_CMAKE_OPTIONS}} -DCMAKE_ABI="x86" - cmake --build . -j $(nproc) - - - name: x86_64 - run: | - mkdir build-x86_64 && cd build-x86_64 - cmake -GNinja .. ${{ env.TILE_CMAKE_OPTIONS}} -DCMAKE_ABI="x86_64" - cmake --build . -j $(nproc) - - - - - diff --git a/CMakeLists.txt b/CMakeLists.txt index 331e011..a164210 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,8 +32,10 @@ option(TILE_BUILD_SHARED "Build shared library" ON) option(TILE_WITH_MIMALLOC "Build with mimalloc" OFF) if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(TILE_BUILD_TESTS ON) - set(TILE_BUILD_BENCHMARKS ON) + if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android") + set(TILE_BUILD_TESTS ON) + set(TILE_BUILD_BENCHMARKS ON) + endif() endif() if(NOT CMAKE_BUILD_TYPE)