orcaslicer/deps/GMP/GMP.cmake
Aidan 17fec83e5b
Flatpak build (#4175)
* Initial commit for the builder

* fix wx, use hack to install into /app

* add some workarounds for /usr/local

* fix up rest of paths

* attempt to fix wxwebview undef

* figure out why wxwidgets isnt getting its patches applied

* do "proper" patching of wxwidgets

* Flip the flag

* actually append the /usr/local

* restrict package finding to flatpak only

* Update the destdir stuff for mpfr, gmp

* Transfer over all the _destdir, again

* update patch command for all other plats

* initial ci check

* what even happened

* clear ci image

* I doubt this will do anything

* do cleanup after running each step

* remove build objects for flatpak ci

* compress debug info

* Fix MacOS build

* Try saving space after building deps

* No debug info for now

* Do debug info, use thin static archives

* use BSD flag, not --thin

* try building with lto

* Use release, no debug info

* remove lto

* Revert the last 5 commits

* It might require write perms

* Revert "It might require write perms"

This reverts commit 44cec58a5713cb5ebbc44e64e314b88b553b8f75.

* Import fixes for merge

* remove some patch stuff

* the worst hack!

* remove uneeded patches

* Initial commit for the builder

* note to self, go back to regular wx

* attempt to fix wxwebview undef

* do "proper" patching of wxwidgets

* update patch command for all other plats

* what even happened

* -ldep_name-NOTFOUND is still here

* concat patches

* Build wx with flatpak

* more wx shenatigans

* fix a missing import

* build wx with proper flags

* fix imports and libs

* trigger ci

* try fixing mac and windows ci

* remove duplicate definition of freetype

* curl may not have openssl for a dep

* has openssl been found?

* force building

* build images on apple

* cleanup for review

* cleanup cmake files

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
2024-05-25 09:11:19 +08:00

67 lines
2.9 KiB
CMake

set(_srcdir ${CMAKE_CURRENT_LIST_DIR}/gmp)
if (MSVC)
set(_output ${DESTDIR}/include/gmp.h
${DESTDIR}/lib/libgmp-10.lib
${DESTDIR}/bin/libgmp-10.dll)
add_custom_command(
OUTPUT ${_output}
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/gmp.h ${DESTDIR}/include/
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.lib ${DESTDIR}/lib/
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.dll ${DESTDIR}/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_arch aarch64)
else ()
set(_gmp_build_arch ${CMAKE_SYSTEM_PROCESSOR})
endif()
if (IS_CROSS_COMPILE)
if (${CMAKE_OSX_ARCHITECTURES} MATCHES "arm")
set(_gmp_host_arch aarch64)
set(_gmp_host_arch_flags "-arch arm64")
elseif (${CMAKE_OSX_ARCHITECTURES} MATCHES "x86_64")
set(_gmp_host_arch x86_64)
set(_gmp_host_arch_flags "-arch x86_64")
endif()
set(_gmp_ccflags "${_gmp_ccflags} ${_gmp_host_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET}")
set(_gmp_build_tgt --build=${_gmp_build_arch}-apple-darwin --host=${_gmp_host_arch}-apple-darwin)
else ()
set(_gmp_ccflags "${_gmp_ccflags} -mmacosx-version-min=${DEP_OSX_TARGET}")
set(_gmp_build_tgt "--build=${_gmp_build_arch}-apple-darwin")
endif()
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/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.2.1/gmp-6.2.1.tar.bz2
URL_HASH SHA256=eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c
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}" ${_gmp_build_tgt}
BUILD_COMMAND make -j
INSTALL_COMMAND make install
)
endif ()