From 754688c9551d4275ed6d704687a33f0568fa73e8 Mon Sep 17 00:00:00 2001 From: Gereon Kremer Date: Wed, 21 Apr 2021 21:33:21 +0200 Subject: [PATCH] Pass GMP to libpoly (#6411) This PR makes sure that our build of libpoly works on systems without GMP: by passing the paths to GMP we use ourselves to libpoly, we make sure libpoly always has a suitable version of GMP. Also, we make libpoly somewhat faster to build by disabling tests. --- cmake/FindPoly.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/FindPoly.cmake b/cmake/FindPoly.cmake index 4521605b9..2030ca806 100644 --- a/cmake/FindPoly.cmake +++ b/cmake/FindPoly.cmake @@ -47,7 +47,7 @@ if(NOT Poly_FOUND_SYSTEM) if(CCWIN) # Roughly following https://stackoverflow.com/a/44383330/2375725 set(patchcmd - PATCH_COMMAND + COMMAND patch /src/CMakeLists.txt ${CMAKE_CURRENT_LIST_DIR}/deps-utils/Poly-patch-cmake.patch @@ -66,19 +66,28 @@ if(NOT Poly_FOUND_SYSTEM) unset(patchcmd) endif() + get_target_property(GMP_INCLUDE_DIR GMP INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(GMP_LIBRARY GMP IMPORTED_LOCATION) + get_filename_component(GMP_LIB_PATH "${GMP_LIBRARY}" DIRECTORY) + ExternalProject_Add( Poly-EP ${COMMON_EP_CONFIG} URL https://github.com/SRI-CSL/libpoly/archive/refs/tags/v${Poly_VERSION}.tar.gz URL_HASH SHA1=7af3bbb7a2bca6ef2a41e79447baac08ff30d2fd DOWNLOAD_NAME libpoly.tar.gz - ${patchcmd} + PATCH_COMMAND + sed -i.orig + "s,add_subdirectory(test/polyxx),add_subdirectory(test/polyxx EXCLUDE_FROM_ALL),g" + /CMakeLists.txt ${patchcmd} CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX= -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DLIBPOLY_BUILD_PYTHON_API=OFF -DLIBPOLY_BUILD_STATIC=ON -DLIBPOLY_BUILD_STATIC_PIC=ON + -DCMAKE_INCLUDE_PATH=${GMP_INCLUDE_DIR} + -DCMAKE_LIBRARY_PATH=${GMP_LIB_PATH} BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} static_pic_poly static_pic_polyxx INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install COMMAND ${CMAKE_COMMAND} -E copy src/libpicpoly.a @@ -93,6 +102,7 @@ if(NOT Poly_FOUND_SYSTEM) DEPENDEES install COMMAND ${CMAKE_COMMAND} -E remove_directory /test/ ) + add_dependencies(Poly-EP GMP) set(Poly_INCLUDE_DIR "${DEPS_BASE}/include/") set(Poly_LIBRARIES "${DEPS_BASE}/lib/libpicpoly.a") -- 2.30.2