From dde048fb4ceda80c4cf60ba70d5953d95c38b12e Mon Sep 17 00:00:00 2001 From: Weiyou Wang Date: Sat, 17 Aug 2024 01:21:34 +1000 Subject: [PATCH] =?UTF-8?q?ci:=20=E5=9C=A8=20macOS=20=E4=B8=8A=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20clang=2018?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 15 +++++++++++---- CMakeLists.txt | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c06a78328f..1ec3f16d51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -296,10 +296,14 @@ jobs: macOS-Core: needs: meta - runs-on: macos-14 strategy: matrix: - arch: [arm64, x86_64] + include: + - os: macos-13 + arch: x86_64 + - os: macos-14 + arch: arm64 + runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -308,7 +312,7 @@ jobs: - name: Install Dependencies run: | - brew install ninja + brew install ninja llvm@18 - name: Bootstrap MaaDeps run: | @@ -319,7 +323,10 @@ jobs: - name: Configure MaaCore run: | - cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES='${{ matrix.arch }}' -DMAA_VERSION='${{ needs.meta.outputs.tag }}' + LLVM_PREFIX=$(brew --prefix llvm) + cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES='${{ matrix.arch }}' -DMAA_VERSION='${{ needs.meta.outputs.tag }}' \ + -DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang \ + -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ - name: Build MaaCore run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index dc7d6c1c07..fb7590f12a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,20 @@ else () endif() endif () +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "18.0") + execute_process( + COMMAND brew --prefix llvm + OUTPUT_VARIABLE LLVM_PREFIX + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + message(STATUS "LLVM prefix=${LLVM_PREFIX}") + target_link_options(MaaCore PRIVATE + "-L${LLVM_PREFIX}/lib/c++" + "-L${LLVM_PREFIX}/lib" + "-lunwind" + ) +endif() + if (WIN32) #注意:相比VS版本缺少了 -D_CONSOLE -D_WINDLL 两项 target_compile_definitions(MaaCore PRIVATE ASST_DLL_EXPORTS _UNICODE UNICODE)