GMP.cmake 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. set(_srcdir ${CMAKE_CURRENT_LIST_DIR}/gmp)
  2. set(_dstdir ${DESTDIR}/usr/local)
  3. if (MSVC)
  4. set(_output ${_dstdir}/include/gmp.h
  5. ${_dstdir}/lib/libgmp-10.lib
  6. ${_dstdir}/bin/libgmp-10.dll)
  7. add_custom_command(
  8. OUTPUT ${_output}
  9. COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/gmp.h ${_dstdir}/include/
  10. COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.lib ${_dstdir}/lib/
  11. COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.dll ${_dstdir}/bin/
  12. )
  13. add_custom_target(dep_GMP SOURCES ${_output})
  14. else ()
  15. set(_gmp_ccflags "-O2 -DNDEBUG -fPIC -DPIC -Wall -Wmissing-prototypes -Wpointer-arith -pedantic -fomit-frame-pointer -fno-common")
  16. set(_gmp_build_tgt "${CMAKE_SYSTEM_PROCESSOR}")
  17. if (APPLE)
  18. if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
  19. set(_gmp_build_tgt aarch64)
  20. endif()
  21. set(_gmp_ccflags "${_gmp_ccflags} -mmacosx-version-min=${DEP_OSX_TARGET}")
  22. set(_gmp_build_tgt "--build=${_gmp_build_tgt}-apple-darwin")
  23. elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  24. if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
  25. set(_gmp_ccflags "${_gmp_ccflags} -march=armv7-a") # Works on RPi-4
  26. set(_gmp_build_tgt armv7)
  27. endif()
  28. set(_gmp_build_tgt "--build=${_gmp_build_tgt}-pc-linux-gnu")
  29. else ()
  30. set(_gmp_build_tgt "") # let it guess
  31. endif()
  32. ExternalProject_Add(dep_GMP
  33. # URL https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2
  34. URL https://gmplib.org/download/gmp/gmp-6.2.1.tar.bz2
  35. BUILD_IN_SOURCE ON
  36. CONFIGURE_COMMAND env "CFLAGS=${_gmp_ccflags}" "CXXFLAGS=${_gmp_ccflags}" ./configure --enable-shared=no --enable-cxx=yes --enable-static=yes "--prefix=${DESTDIR}/usr/local" ${_gmp_build_tgt}
  37. BUILD_COMMAND make -j
  38. INSTALL_COMMAND make install
  39. )
  40. endif ()