forked from bambulab/BambuStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGMP.cmake
54 lines (46 loc) · 2.2 KB
/
GMP.cmake
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
set(_srcdir ${CMAKE_CURRENT_LIST_DIR}/gmp)
set(_dstdir ${DESTDIR}/usr/local)
if (MSVC)
set(_output ${_dstdir}/include/gmp.h
${_dstdir}/lib/libgmp-10.lib
${_dstdir}/bin/libgmp-10.dll)
add_custom_command(
OUTPUT ${_output}
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/gmp.h ${_dstdir}/include/
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.lib ${_dstdir}/lib/
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.dll ${_dstdir}/bin/
)
add_custom_target(dep_GMP SOURCES ${_output})
else ()
set(_gmp_ccflags "-O2 -DNDEBUG -fPIC -DPIC -Wall -Wmissing-prototypes -Wpointer-arith -pedantic -fomit-frame-pointer -fno-common")
set(_gmp_build_tgt "${CMAKE_SYSTEM_PROCESSOR}")
if (APPLE)
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
set(_gmp_build_tgt aarch64)
endif()
set(_gmp_ccflags "${_gmp_ccflags} -mmacosx-version-min=${DEP_OSX_TARGET}")
set(_gmp_build_tgt "--build=${_gmp_build_tgt}-apple-darwin")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
set(_gmp_ccflags "${_gmp_ccflags} -march=armv7-a") # Works on RPi-4
set(_gmp_build_tgt armv7)
endif()
set(_gmp_build_tgt "--build=${_gmp_build_tgt}-pc-linux-gnu")
else ()
set(_gmp_build_tgt "") # let it guess
endif()
set(_cross_compile_arg "")
if (CMAKE_CROSSCOMPILING)
# TOOLCHAIN_PREFIX should be defined in the toolchain file
set(_cross_compile_arg --host=${TOOLCHAIN_PREFIX})
endif ()
ExternalProject_Add(dep_GMP
URL https://github.com/bambulab/gmp/archive/refs/tags/6.2.1.tar.gz
URL_HASH SHA256=705ae57ee2014b2c6fc0f572c85ee43276b99b6b256ee16c1a9d3a8c4e3609d5
DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/GMP
BUILD_IN_SOURCE ON
CONFIGURE_COMMAND env "CFLAGS=${_gmp_ccflags}" "CXXFLAGS=${_gmp_ccflags}" ./configure ${_cross_compile_arg} --enable-shared=no --enable-cxx=yes --enable-static=yes "--prefix=${DESTDIR}/usr/local" ${_gmp_build_tgt}
BUILD_COMMAND make -j
INSTALL_COMMAND make install
)
endif ()