aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/mpir/portfile.cmake
blob: 3ce9ca3b2f8c204bbb00cbfd7c5e9582390f3e5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
if(EXISTS "${CURRENT_INSTALLED_DIR}/include/gmp.h" OR EXISTS "${CURRENT_INSTALLED_DIR}/include/gmpxx.h")
    message(FATAL_ERROR "Can't build ${PORT} if gmp is installed. Please remove gmp, and try to install ${PORT} again if you need it.")
endif()

vcpkg_from_github(
    OUT_SOURCE_PATH SOURCE_PATH
    REPO wbhart/mpir
    REF cdd444aedfcbb190f00328526ef278428702d56e # 3.0.0
    SHA512 f46e45bdba27c9f89953ba23186b694486fd3010bd370ea2de71a4649a2816e716a6520c9baa96936f1884437ef03f92b21c0b1fb5b757beba5a05fed30b2bfc
    HEAD_REF master
    PATCHES 
        enable-runtimelibrary-toggle.patch
        fix-static-include-files.patch
)

if(NOT VCPKG_TARGET_IS_WINDOWS)
    vcpkg_find_acquire_program(YASM)

    set(SHARED_STATIC --disable-static --enable-shared)
    if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
        set(SHARED_STATIC --enable-static --disable-shared --with-pic)
    endif()

    set(OPTIONS --disable-silent-rules --enable-gmpcompat --enable-cxx ${SHARED_STATIC})

    string(APPEND VCPKG_C_FLAGS " -Wno-implicit-function-declaration")
    string(APPEND VCPKG_CXX_FLAGS " -Wno-implicit-function-declaration")

    # on Linux, autoconf is required; on macOS, it isn't
    if(VCPKG_TARGET_IS_LINUX)
        set(AUTOCONFIG "AUTOCONFIG")
    endif()

    vcpkg_configure_make(
        SOURCE_PATH "${SOURCE_PATH}"
        ${AUTOCONFIG}
        OPTIONS ${OPTIONS}
    )
    vcpkg_install_make()
else()
    set(MSVC_VERSION 14)
    if(VCPKG_PLATFORM_TOOLSET MATCHES "v14(1|2|3)")
        set(MSVC_VERSION 15)
    endif()

    set(DLL_OR_LIB dll)
    if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
        set(DLL_OR_LIB lib)
    endif()

    # Note: Could probably be moved to use vcpkg_configure_make on windows
    vcpkg_msbuild_install(
        SOURCE_PATH "${SOURCE_PATH}"
        PROJECT_SUBPATH "build.vc${MSVC_VERSION}/${DLL_OR_LIB}_mpir_gc/${DLL_OR_LIB}_mpir_gc.vcxproj"
    )

    if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
        vcpkg_msbuild_install(
            SOURCE_PATH "${SOURCE_PATH}"
            PROJECT_SUBPATH "build.vc${MSVC_VERSION}/${DLL_OR_LIB}_mpir_cxx/${DLL_OR_LIB}_mpir_cxx.vcxproj"
        )
    endif()

    file(GLOB HEADERS
        "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*/*/Release/gmp.h"
        "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*/*/Release/gmpxx.h"
        "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*/*/Release/mpir.h"
        "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*/*/Release/mpirxx.h"
    )
    file(INSTALL ${HEADERS} DESTINATION "${CURRENT_PACKAGES_DIR}/include")

    file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/COPYING.LIB" "${CURRENT_PACKAGES_DIR}/debug/lib/COPYING.LIB")
endif()

if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
    file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(REMOVE_RECURSE
        "${CURRENT_PACKAGES_DIR}/debug/include"
        "${CURRENT_PACKAGES_DIR}/debug/share"
    )

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING" "${SOURCE_PATH}/COPYING.LIB")