From 2dd72be036a1d8825f394a500c3ccfeaaf6b8c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Fri, 13 Sep 2024 18:16:37 +0200 Subject: [PATCH] Fix Windows ARM64 support with regards to Mesa 3D - Only fail the Mesa 3D arch check, if it's been enabled - Add a cross-compilation CI job for Windows ARM64 - Fix ARM64 architecture detection for the Ninja generator --- .github/workflows/ci.yml | 7 ++++--- cmake/Config.cmake | 4 +--- cmake/Mesa3D.cmake | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 317d34826..013c69f1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ jobs: - { name: Windows VS2019 x64, os: windows-2019, flags: -DSFML_USE_MESA3D=ON -GNinja } - { name: Windows VS2022 x86, os: windows-2022, flags: -DSFML_USE_MESA3D=ON -GNinja } - { name: Windows VS2022 x64, os: windows-2022, flags: -DSFML_USE_MESA3D=ON -GNinja } + - { name: Windows VS2022 arm64, os: windows-2022, flags: -DSFML_USE_MESA3D=OFF -GNinja -DSFML_BUILD_TEST_SUITE=OFF } - { name: Windows VS2022 ClangCL MSBuild, os: windows-2022, flags: -DSFML_USE_MESA3D=ON -T ClangCL } # ninja doesn't support specifying the toolset, so use the ClangCL toolset to test building with MSBuild as well - { name: Windows VS2022 OpenGL ES, os: windows-2022, flags: -DSFML_USE_MESA3D=ON -DSFML_OPENGL_ES=ON -GNinja } - { name: Windows VS2022 Unity, os: windows-2022, flags: -DSFML_USE_MESA3D=ON -DCMAKE_UNITY_BUILD=ON -GNinja } @@ -117,7 +118,7 @@ jobs: if: contains(matrix.platform.name, 'Windows VS') && !contains(matrix.platform.name, 'MSBuild') uses: ilammy/msvc-dev-cmd@v1 with: - arch: ${{ contains(matrix.platform.name, 'x86') && 'x86' || 'x64' }} + arch: ${{ contains(matrix.platform.name, 'arm64') && 'amd64_arm64' || contains(matrix.platform.name, 'x86') && 'x86' || 'x64' }} # Although the CMake configuration will run with 3.24 on Windows and 3.22 # elsewhere, we install 3.25 on Windows in order to support specifying @@ -237,7 +238,7 @@ jobs: find build/bin -name test-sfml-window -or -name test-sfml-window.exe -exec sh -c "{} *sf::Context* --section=\"Version String\" --success | grep OpenGL" \; - name: Test (Windows) - if: runner.os == 'Windows' && !contains(matrix.platform.name, 'MinGW') + if: runner.os == 'Windows' && !contains(matrix.platform.name, 'MinGW') && !contains(matrix.platform.name, 'arm64') run: cmake --build build --target runtests --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} - name: Test (Linux/macOS/MinGW) @@ -291,7 +292,7 @@ jobs: ctest --test-dir build --output-on-failure -C ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} --repeat until-pass:3 - name: Upload Coverage Report to Coveralls - if: matrix.type.name == 'Debug' && github.repository == 'SFML/SFML' && !contains(matrix.platform.name, 'iOS') && !contains(matrix.platform.name, 'Android') # Disable upload in forks + if: matrix.type.name == 'Debug' && github.repository == 'SFML/SFML' && !contains(matrix.platform.name, 'iOS') && !contains(matrix.platform.name, 'Android') && !contains(matrix.platform.name, 'arm64') # Disable upload in forks uses: coverallsapp/github-action@v2 with: file: ./build/coverage.out diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 35dc26ede..7e5e0c795 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -6,9 +6,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(OPENGL_ES 0) # detect the architecture - if(${CMAKE_GENERATOR_PLATFORM} MATCHES "ARM64") - set(ARCH_ARM64 1) - elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "ARM64") + if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "ARM64" OR "${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "ARM64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "ARM64") set(ARCH_ARM64 1) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) set(ARCH_X86 1) diff --git a/cmake/Mesa3D.cmake b/cmake/Mesa3D.cmake index e5970fa75..2889fc64f 100644 --- a/cmake/Mesa3D.cmake +++ b/cmake/Mesa3D.cmake @@ -4,11 +4,11 @@ set(MESA3D_SHA256 "FEF8A643689414A70347AE8027D24674DEFD85E8D6428C8A9D4145BB3F44A get_filename_component(MESA3D_ARCHIVE "${MESA3D_URL}" NAME) get_filename_component(MESA3D_ARCHIVE_DIRECTORY "${MESA3D_URL}" NAME_WLE) -if(${ARCH_X64}) +if(ARCH_X64) set(MESA3D_ARCH "x64") -elseif(${ARCH_X86}) +elseif(ARCH_X86) set(MESA3D_ARCH "x86") -else() +elseif(SFML_USE_MESA3D) message(FATAL_ERROR "Mesa 3D does currently not support the target architecture.") endif() @@ -61,7 +61,7 @@ if(SFML_OS_WINDOWS AND SFML_USE_MESA3D) add_custom_target(install-mesa3d DEPENDS ${MESA3D_INSTALLED_FILES}) set_target_properties(install-mesa3d PROPERTIES EXCLUDE_FROM_ALL ON) -elseif(SFML_OS_WINDOWS AND EXISTS "${MESA3D_ARCH_PATH}") +elseif(SFML_OS_WINDOWS AND MESA3D_ARCH AND EXISTS "${MESA3D_ARCH_PATH}") # we are removing the files # compile a list of file names that we have to remove