Skip to content

Commit 449ce01

Browse files
committed
Fix arch detection for MSVC cross-compile, skip tests for x86/ARM64
- Use CMAKE_GENERATOR_PLATFORM to detect target arch on MSVC (Win32/ARM64) instead of CMAKE_SYSTEM_PROCESSOR which always reports the host arch - Only run tests for x64 and Linux (native arch); x86/ARM64 are build-only because 32-bit ODBC registration on 64-bit CI is unreliable and ARM64 binaries cannot execute on x64 hosts
1 parent cff7c00 commit 449ce01

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

.github/workflows/build-and-test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,17 @@ jobs:
4949
run: sudo apt-get update && sudo apt-get install -y unixodbc unixodbc-dev
5050

5151
- name: Build, install and test
52-
if: matrix.arch != 'ARM64'
52+
if: ${{ !matrix.arch || matrix.arch == 'x64' }}
5353
shell: pwsh
5454
env:
5555
API_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56-
run: Invoke-Build test -Configuration Release -Architecture ${{ matrix.arch }} -File ./firebird-odbc-driver.build.ps1
56+
run: |
57+
$archArgs = @{}
58+
if ('${{ matrix.arch }}') { $archArgs['Architecture'] = '${{ matrix.arch }}' }
59+
Invoke-Build test -Configuration Release @archArgs -File ./firebird-odbc-driver.build.ps1
5760
5861
- name: Build only (cross-compile)
59-
if: matrix.arch == 'ARM64'
62+
if: ${{ matrix.arch && matrix.arch != 'x64' }}
6063
shell: pwsh
6164
env:
6265
API_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,19 @@ option(BUILD_TESTING "Build tests" ON)
4444
# ---------------------------------------------------------------------------
4545
# CPU architecture detection (from PR #248)
4646
# ---------------------------------------------------------------------------
47-
# Prefer CMAKE_SYSTEM_PROCESSOR (correct for cross-compilation, e.g. -A Win32
48-
# or -A ARM64 on MSVC), fall back to CMAKE_HOST_SYSTEM_PROCESSOR for native.
49-
if(CMAKE_SYSTEM_PROCESSOR)
47+
# On MSVC multi-config generators, -A Win32/ARM64 sets CMAKE_GENERATOR_PLATFORM
48+
# but CMAKE_SYSTEM_PROCESSOR stays as the host arch. Use the generator platform
49+
# when available to get the correct target architecture.
50+
if(CMAKE_GENERATOR_PLATFORM)
51+
string(TOUPPER "${CMAKE_GENERATOR_PLATFORM}" _PLAT)
52+
if(_PLAT STREQUAL "WIN32")
53+
set(FBODBC_ARCH "x86")
54+
elseif(_PLAT STREQUAL "ARM64")
55+
set(FBODBC_ARCH "ARM64")
56+
else()
57+
set(FBODBC_ARCH "${CMAKE_GENERATOR_PLATFORM}")
58+
endif()
59+
elseif(CMAKE_SYSTEM_PROCESSOR)
5060
set(FBODBC_ARCH ${CMAKE_SYSTEM_PROCESSOR})
5161
else()
5262
set(FBODBC_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})

0 commit comments

Comments
 (0)