From: Andres Noetzli Date: Tue, 26 Apr 2022 02:06:19 +0000 (-0700) Subject: Fix GMP cross-compilation when Wine installed (#8645) X-Git-Tag: cvc5-1.0.1~224 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b0500dd28ec42d6a1bada80d34b74ce8aea896cc;p=cvc5.git Fix GMP cross-compilation when Wine installed (#8645) When Wine is installed on the system, our current invocation of GMP's `configure` fails. To fix the issue, we pass `CC_FOR_BUILD` that is used to compile build-time programs. When compiling GMP with `--enable-cxx`, it also seems to be necessary to pass `--build` to make `configure` pass. Passing `--build` for cross-compilation builds is also recommended by the [GMP documentation](https://gmplib.org/manual/Build-Options). --- diff --git a/cmake/FindGMP.cmake b/cmake/FindGMP.cmake index c4ed3fc20..38771692a 100644 --- a/cmake/FindGMP.cmake +++ b/cmake/FindGMP.cmake @@ -65,15 +65,24 @@ if(NOT GMP_FOUND_SYSTEM) set(GMP_LIBRARIES "${DEPS_BASE}/lib/libgmp.a") endif() - + # `CC_FOR_BUILD`, `--host`, and `--build` are passed to `configure` to ensure + # that cross-compilation works (as suggested in the GMP documentation). + # Without the `--build` flag, `configure` may fail for cross-compilation + # builds for Windows if Wine is installed. ExternalProject_Add( GMP-EP ${COMMON_EP_CONFIG} URL https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2 URL_HASH SHA1=2dcf34d4a432dbe6cce1475a835d20fe44f75822 CONFIGURE_COMMAND - /configure ${LINK_OPTS} --prefix= - --with-pic --enable-cxx --host=${TOOLCHAIN_PREFIX} + ${CMAKE_COMMAND} -E env CC_FOR_BUILD=cc + /configure + ${LINK_OPTS} + --prefix= + --with-pic + --enable-cxx + --host=${TOOLCHAIN_PREFIX} + --build=${CMAKE_HOST_SYSTEM_PROCESSOR} BUILD_BYPRODUCTS ${GMP_LIBRARIES} ) endif()