From c0090ed4c98dbad3fe855f3ac3b9908e037afa03 Mon Sep 17 00:00:00 2001 From: xoviat Date: Fri, 3 Nov 2017 19:57:33 -0500 Subject: [PATCH] Add arblib (#1991) --- ports/arb/CMakeLists.txt | 94 ++++++++++++++++++++++++++++++++++++++++ ports/arb/CONTROL | 4 ++ ports/arb/portfile.cmake | 32 ++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 ports/arb/CMakeLists.txt create mode 100644 ports/arb/CONTROL create mode 100644 ports/arb/portfile.cmake diff --git a/ports/arb/CMakeLists.txt b/ports/arb/CMakeLists.txt new file mode 100644 index 0000000000..3474c9974a --- /dev/null +++ b/ports/arb/CMakeLists.txt @@ -0,0 +1,94 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(arb C) + +set (DEPS mpir mpfr pthreads flint2 gettimeofday) +set (mpir_lib gmp mpir) +set (mpfr_lib mpfr) +set (pthreads_lib pthreads pthread) +set (flint2_lib ${LIBRARY_TYPE}_flint flint) +set (gettimeofday_lib gettimeofday) + +set (mpir_header gmp.h) +set (mpfr_header mpfr.h) +set (pthreads_header pthread.h) +set (flint2_header flint/flint.h) +set (gettimeofday_header gettimeofday.h) + +foreach (LIB ${DEPS}) + string (TOUPPER ${LIB} LIB_UPPER) + find_library(${LIB_UPPER}_LIBRARY NAMES ${${LIB}_lib}) + if (NOT ${LIB_UPPER}_LIBRARY) + message(FATAL_ERROR "${LIB} library not found.") + endif() + add_library(${LIB} UNKNOWN IMPORTED) + set_property(TARGET ${LIB} PROPERTY IMPORTED_LOCATION ${${LIB_UPPER}_LIBRARY}) + message("${LIB} found in ${${LIB_UPPER}_LIBRARY}") +endforeach () + +foreach (LIB ${DEPS}) + string(TOUPPER ${LIB} HEADER_PKG) + set (HEADER ${${LIB}_header}) + find_path(${HEADER_PKG}_INCLUDE_DIR NAMES ${HEADER}) + if (NOT ${HEADER_PKG}_INCLUDE_DIR) + message(FATAL_ERROR "${HEADER} header not found.") + endif() + message("${HEADER} found in ${${HEADER_PKG}_INCLUDE_DIR}") + set (DEP_INCLUDE_DIRS ${DEP_INCLUDE_DIRS} ${${HEADER_PKG}_INCLUDE_DIR}) +endforeach () + +file(GLOB TEMP "*.h") + +foreach (TEMP_H ${TEMP}) + get_filename_component(FOLDER ${TEMP_H} NAME_WE) + set(FOLDERS ${FOLDERS} ${FOLDER}) +endforeach() + +foreach (FOLDER ${FOLDERS}) + file(GLOB TEMP "${FOLDER}/*.c") + set(SRC ${SRC} ${TEMP}) +endforeach () + +include_directories(BEFORE ${arb_SOURCE_DIR}) +include_directories(BEFORE ${DEP_INCLUDE_DIRS}) + +add_library(arb ${SRC}) + +target_compile_definitions(arb PRIVATE HAVE_TLS=1 FLINT_REENTRANT=0) +if (BUILD_SHARED_LIBS) + target_compile_definitions(arb PRIVATE MSC_USE_DLL) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS yes) + MESSAGE( STATUS "Building shared libraries" ) +else () + target_compile_definitions(arb PRIVATE PTW32_STATIC_LIB) + MESSAGE( STATUS "Building static libraries" ) +endif() +target_compile_definitions(arb PRIVATE "ARB_BUILD_DLL") + +target_link_libraries(arb ${DEPS}) + +install(TARGETS arb + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + ) + +foreach (FOLDER ${FOLDERS}) + set(HEADERS ${HEADERS} ${FOLDER}.h) +endforeach () + +install(FILES ${HEADERS} DESTINATION include) + +if (BUILD_TESTS) + enable_testing() + foreach (FOLDER ${FOLDERS}) + file(GLOB TEMP "${FOLDER}/test/*.c") + foreach (TEST_SOURCE ${TEMP}) + get_filename_component(TEST_NAME ${TEST_SOURCE} NAME_WE) + add_executable(${FOLDER}-${TEST_NAME} ${TEST_SOURCE}) + target_link_libraries(${FOLDER}-${TEST_NAME} arb) + add_test(${FOLDER}-${TEST_NAME} ${FOLDER}-${TEST_NAME}) + endforeach () + endforeach () +endif () + diff --git a/ports/arb/CONTROL b/ports/arb/CONTROL new file mode 100644 index 0000000000..2166fd1e05 --- /dev/null +++ b/ports/arb/CONTROL @@ -0,0 +1,4 @@ +Source: arb +Version: 2.11.1 +Description: a C library for arbitrary-precision interval arithmetic +Build-Depends: flint diff --git a/ports/arb/portfile.cmake b/ports/arb/portfile.cmake new file mode 100644 index 0000000000..234ce17788 --- /dev/null +++ b/ports/arb/portfile.cmake @@ -0,0 +1,32 @@ +if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + message(STATUS "Warning: Dynamic building not supported yet. Building static.") + set(VCPKG_LIBRARY_LINKAGE static) +endif() + +include(vcpkg_common_functions) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/arb-2.11.1) + +vcpkg_from_github( + OUT_SOURCE_PATH ${SOURCE_PATH} + REPO fredrik-johansson/arb + REF 2.11.1 + SHA512 7a014da5208b55f20c7a3cd3eb51070b09ae107b04cbbd6329925780c2ab4d7c38e1fb3619f21456fa806939818370fcae921f59eb013661b6bdd3d0971e3353 + HEAD_REF master +) + +file(REMOVE ${SOURCE_PATH}/CMakeLists.txt) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} +) + +vcpkg_install_cmake() +vcpkg_copy_pdbs() + + +# Handle copyright +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/arb RENAME copyright) + +# Remove duplicate headers +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)