[Win64] Use `CC_FOR_BUILD` when compiling GMP (#8874)
authorAndres Noetzli <andres.noetzli@gmail.com>
Fri, 10 Jun 2022 23:17:21 +0000 (16:17 -0700)
committerGitHub <noreply@github.com>
Fri, 10 Jun 2022 23:17:21 +0000 (16:17 -0700)
This restores the use of the `CC_FOR_BUILD` environment variable. It was
(accidentally) removed in 4337cdb8e2a071ded73dbc9236c8bb2f4d42e6e5 after
it was added in b0500dd28ec42d6a1bada80d34b74ce8aea896cc. Without
`CC_FOR_BUILD`, cross-compilation of GMP fails on Arch Linux.

cmake/FindGMP.cmake

index 2e2afb89817524998308409fc8281fb5a9fb7e41..bbbc2017b0abbc9fd81facdd61c7a61501ce998f 100644 (file)
@@ -91,11 +91,15 @@ if(NOT GMP_FOUND_SYSTEM)
     set(CONFIGURE_OPTS
       --host=${TOOLCHAIN_PREFIX}
       --build=${CMAKE_HOST_SYSTEM_PROCESSOR})
-  endif()
-  if (CMAKE_CROSSCOMPILING_MACOS)
+
     set(CONFIGURE_ENV ${CMAKE_COMMAND} -E
-      env "CFLAGS=--target=${TOOLCHAIN_PREFIX}"
-      env "LDFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES}")
+      env "CC_FOR_BUILD=cc")
+    if (CMAKE_CROSSCOMPILING_MACOS)
+      set(CONFIGURE_ENV
+        ${CONFIGURE_ENV}
+        env "CFLAGS=--target=${TOOLCHAIN_PREFIX}"
+        env "LDFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES}")
+    endif()
   endif()
 
   # `CC_FOR_BUILD`, `--host`, and `--build` are passed to `configure` to ensure