From fed89a962572bdc5a4259314c95e458c82b5b3e4 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Mon, 22 Oct 2018 17:04:51 -0700 Subject: [PATCH] [mpir] Fix Linux builds --- ports/mpir/CONTROL | 2 +- ports/mpir/portfile.cmake | 188 +++++++++++++++++++++++--------------- 2 files changed, 114 insertions(+), 76 deletions(-) diff --git a/ports/mpir/CONTROL b/ports/mpir/CONTROL index 22216d41d1..7a8dd7985e 100644 --- a/ports/mpir/CONTROL +++ b/ports/mpir/CONTROL @@ -1,3 +1,3 @@ Source: mpir -Version: 3.0.0-4 +Version: 3.0.0-5 Description: Multiple Precision Integers and Rationals. diff --git a/ports/mpir/portfile.cmake b/ports/mpir/portfile.cmake index c352b657a6..5f54fa08f7 100644 --- a/ports/mpir/portfile.cmake +++ b/ports/mpir/portfile.cmake @@ -8,91 +8,129 @@ if(VCPKG_CRT_LINKAGE STREQUAL "static" AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynam message(FATAL_ERROR "MPIR currently can only be built using the dynamic CRT when building DLLs") endif() -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO wbhart/mpir - REF mpir-3.0.0 - SHA512 7d37f60645c533a6638dde5d9c48f5535022fa0ea02bafd5b714649c70814e88c5e5e3b0bef4c5a749aaf8772531de89c331716ee00ba1c2f9521c2cc8f3c61b - HEAD_REF master -) +set(MPIR_VERSION 3.0.0) -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES "${CMAKE_CURRENT_LIST_DIR}/enable-runtimelibrary-toggle.patch" -) - -if(VCPKG_PLATFORM_TOOLSET MATCHES "v141") - set(MSVC_VERSION 15) -else() - set(MSVC_VERSION 14) -endif() - -if (VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") - vcpkg_build_msbuild( - PROJECT_PATH ${SOURCE_PATH}/build.vc${MSVC_VERSION}/dll_mpir_gc/dll_mpir_gc.vcxproj +if(VCPKG_CMAKE_SYSTEM_NAME) + vcpkg_download_distfile( + ARCHIVE + URLS "http://mpir.org/mpir-${MPIR_VERSION}.tar.bz2" + FILENAME mpir-${MPIR_VERSION}.tar.bz2 + SHA512 c735105db8b86db739fd915bf16064e6bc82d0565ad8858059e4e93f62c9d72d9a1c02a5ca9859b184346a8dc64fa714d4d61404cff1e405dc548cbd54d0a88e ) + + vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + REF ${MPIR_VERSION} + ) + + vcpkg_find_acquire_program(YASM) + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(SHARED_STATIC --enable-static --disable-shared) + else() + set(SHARED_STATIC --disable-static --enable-shared) + endif() + + set(OPTIONS --disable-silent-rules --enable-gmpcompat --enable-cxx ${SHARED_STATIC}) + + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + message(STATUS "Configuring ${TARGET_TRIPLET}-dbg") + set(ENV{CXXFLAGS} "${VCPKG_CXX_FLAGS} ${VCPKG_CXX_FLAGS_DEBUG} -O0 -g") + set(ENV{CFLAGS} "${VCPKG_C_FLAGS} ${VCPKG_C_FLAGS_DEBUG} -O0 -g") + set(ENV{LDFLAGS} "${VCPKG_LINKER_FLAGS}") + vcpkg_execute_required_process( + COMMAND ${SOURCE_PATH}/configure --prefix=${CURRENT_PACKAGES_DIR}/debug ${OPTIONS} --with-sysroot=${CURRENT_INSTALLED_DIR}/debug + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME configure-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Building ${TARGET_TRIPLET}-dbg") + vcpkg_execute_required_process( + COMMAND make -j install + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME install-${TARGET_TRIPLET}-dbg + ) + + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + message(STATUS "Configuring ${TARGET_TRIPLET}-rel") + set(ENV{CXXFLAGS} "${VCPKG_CXX_FLAGS} ${VCPKG_CXX_FLAGS_RELEASE} -O2") + set(ENV{CFLAGS} "${VCPKG_C_FLAGS} ${VCPKG_C_FLAGS_RELEASE} -O2") + set(ENV{LDFLAGS} "${VCPKG_LINKER_FLAGS}") + vcpkg_execute_required_process( + COMMAND ${SOURCE_PATH}/configure --prefix=${CURRENT_PACKAGES_DIR} ${OPTIONS} --with-sysroot=${CURRENT_INSTALLED_DIR} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME configure-${TARGET_TRIPLET}-rel + ) + message(STATUS "Building ${TARGET_TRIPLET}-rel") + vcpkg_execute_required_process( + COMMAND make -j install + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME install-${TARGET_TRIPLET}-rel + ) + + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/share ${CURRENT_PACKAGES_DIR}/share/info) + configure_file(${SOURCE_PATH}/COPYING.lib ${CURRENT_PACKAGES_DIR}/share/mpir/copyright COPYONLY) else() + vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO wbhart/mpir + REF mpir-${MPIR_VERSION} + SHA512 7d37f60645c533a6638dde5d9c48f5535022fa0ea02bafd5b714649c70814e88c5e5e3b0bef4c5a749aaf8772531de89c331716ee00ba1c2f9521c2cc8f3c61b + HEAD_REF master + PATCHES enable-runtimelibrary-toggle.patch + ) + + if(VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(MSVC_VERSION 15) + else() + set(MSVC_VERSION 14) + endif() + + if (VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(DLL_OR_LIB dll) + else() + set(DLL_OR_LIB lib) + endif() + if(VCPKG_CRT_LINKAGE STREQUAL "static") set(RuntimeLibraryExt "") else() set(RuntimeLibraryExt "DLL") endif() + + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}) + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}) + file(GLOB FILES ${SOURCE_PATH}/*) + file(COPY ${FILES} DESTINATION ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}) + vcpkg_build_msbuild( - PROJECT_PATH ${SOURCE_PATH}/build.vc${MSVC_VERSION}/lib_mpir_gc/lib_mpir_gc.vcxproj + PROJECT_PATH ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/build.vc${MSVC_VERSION}/${DLL_OR_LIB}_mpir_gc/${DLL_OR_LIB}_mpir_gc.vcxproj OPTIONS_DEBUG "/p:RuntimeLibrary=MultiThreadedDebug${RuntimeLibraryExt}" OPTIONS_RELEASE "/p:RuntimeLibrary=MultiThreaded${RuntimeLibraryExt}" ) + + file(GLOB HEADERS + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/*/*/Release/gmp.h + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/*/*/Release/gmpxx.h + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/*/*/Release/mpir.h + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/*/*/Release/mpirxx.h + ) + file(COPY ${HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include) + + file(GLOB REL_DLLS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/*/*/Release/mpir.dll) + file(GLOB REL_LIBS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/*/*/Release/mpir.lib) + + file(GLOB DBG_DLLS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/*/*/Debug/mpir.dll) + file(GLOB DBG_LIBS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/*/*/Debug/mpir.lib) + + file(COPY ${REL_DLLS} DESTINATION ${CURRENT_PACKAGES_DIR}/bin) + file(COPY ${REL_LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/lib) + file(COPY ${DBG_DLLS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + file(COPY ${DBG_LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + + vcpkg_copy_pdbs() + + configure_file(${SOURCE_PATH}/COPYING.lib ${CURRENT_PACKAGES_DIR}/share/mpir/copyright COPYONLY) endif() - -IF (VCPKG_TARGET_ARCHITECTURE MATCHES "x86") - SET(BUILD_ARCH "Win32") -ELSE() - SET(BUILD_ARCH ${VCPKG_TARGET_ARCHITECTURE}) -ENDIF() - -if (VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") - file(INSTALL - ${SOURCE_PATH}/dll/${BUILD_ARCH}/Debug/gmp.h - ${SOURCE_PATH}/dll/${BUILD_ARCH}/Debug/gmpxx.h - ${SOURCE_PATH}/dll/${BUILD_ARCH}/Debug/mpir.h - ${SOURCE_PATH}/dll/${BUILD_ARCH}/Debug/mpirxx.h - DESTINATION ${CURRENT_PACKAGES_DIR}/include - ) - file(INSTALL - ${SOURCE_PATH}/dll/${BUILD_ARCH}/Debug/mpir.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin - ) - file(INSTALL - ${SOURCE_PATH}/dll/${BUILD_ARCH}/Release/mpir.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/bin - ) - file(INSTALL - ${SOURCE_PATH}/dll/${BUILD_ARCH}/Debug/mpir.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib - ) - file(INSTALL - ${SOURCE_PATH}/dll/${BUILD_ARCH}/Release/mpir.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/lib - ) -else() - file(INSTALL - ${SOURCE_PATH}/lib/${BUILD_ARCH}/Debug/gmp.h - ${SOURCE_PATH}/lib/${BUILD_ARCH}/Debug/gmpxx.h - ${SOURCE_PATH}/lib/${BUILD_ARCH}/Debug/mpir.h - ${SOURCE_PATH}/lib/${BUILD_ARCH}/Debug/mpirxx.h - DESTINATION ${CURRENT_PACKAGES_DIR}/include - ) - file(INSTALL - ${SOURCE_PATH}/lib/${BUILD_ARCH}/Debug/mpir.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib - ) - file(INSTALL - ${SOURCE_PATH}/lib/${BUILD_ARCH}/Release/mpir.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/lib - ) -endif() - -file(INSTALL ${SOURCE_PATH}/COPYING.lib DESTINATION ${CURRENT_PACKAGES_DIR}/share/mpir RENAME copyright) -vcpkg_copy_pdbs() - -message(STATUS "Installing done")