Skip to content

Commit 2ab05d5

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge pull request #3327 from dennisameling/fix-host-cpu
cmake(): allow setting HOST_CPU for cross-compilation
2 parents 28c69d5 + 08062a3 commit 2ab05d5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ jobs:
201201
shell: bash
202202
run: |
203203
cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/${{ matrix.arch }}-windows \
204-
-DNO_GETTEXT=YesPlease -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON -DCMAKE_GENERATOR_PLATFORM=${{ matrix.arch }} -DVCPKG_ARCH=${{ matrix.arch }}-windows
204+
-DNO_GETTEXT=YesPlease -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON -DCMAKE_GENERATOR_PLATFORM=${{ matrix.arch }} -DVCPKG_ARCH=${{ matrix.arch }}-windows -DHOST_CPU=${{ matrix.arch }}
205205
- name: MSBuild
206206
run: msbuild git.sln -property:Configuration=Release -property:Platform=${{ matrix.arch }} -maxCpuCount:4 -property:PlatformToolset=v142
207207
- name: bundle artifact tar

contrib/buildsystems/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,14 @@ endif()
223223

224224
#default behaviour
225225
include_directories(${CMAKE_SOURCE_DIR})
226-
add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
226+
227+
# When cross-compiling, define HOST_CPU as the canonical name of the CPU on
228+
# which the built Git will run (for instance "x86_64").
229+
if(NOT HOST_CPU)
230+
add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
231+
else()
232+
add_compile_definitions(GIT_HOST_CPU="${HOST_CPU}")
233+
endif()
227234
add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
228235
add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
229236
SHA1DC_INIT_SAFE_HASH_DEFAULT=0

0 commit comments

Comments
 (0)