From 34ea42394dc81ff7556fd1ac0c2034f47ed8a878 Mon Sep 17 00:00:00 2001 From: Ciaran Welsh Date: Thu, 8 Oct 2020 13:49:37 -0700 Subject: [PATCH] [libsbml] New port for libsbml (#13524) Co-authored-by: JackBoosY --- ports/libsbml/CONTROL | 49 ++++++++++++++++ ports/libsbml/fix-linkage-type.patch | 22 ++++++++ ports/libsbml/portfile.cmake | 83 ++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 ports/libsbml/CONTROL create mode 100644 ports/libsbml/fix-linkage-type.patch create mode 100644 ports/libsbml/portfile.cmake diff --git a/ports/libsbml/CONTROL b/ports/libsbml/CONTROL new file mode 100644 index 00000000000..654ea75bd13 --- /dev/null +++ b/ports/libsbml/CONTROL @@ -0,0 +1,49 @@ +Source: libsbml +Version: 5.18.0 +Description: A library for reading / writing SBML files +Default-Features: expat,comp,fbc,groups,layout,render,libxml2 +Supports: !uwp + +Feature: test +Description: Unit testing of libSBMLs implementation +Build-Depends: check + +Feature: bzip2 +Description: bz2 compression support for libsbml +Build-Depends: bzip2 + +Feature: zlib +Description: gzip compression support for libsbml +Build-Depends: zlib + +Feature: expat +Description: libsbml using expat parser +Build-Depends: expat + +Feature: libxml2 +Description: libsbml using libxml2 parser +Build-Depends: libxml2 + +Feature: comp +Description: support for Hierarchical Model Composition + +Feature: fbc +Description: support for Flux Balance Constrant Modeling + +Feature: groups +Description: support for Groups + +Feature: layout +Description: support for Pathway Layouts + +Feature: multi +Description: support for Multistate Modeling + +Feature: qual +Description: support for Qualitative Modeling + +Feature: render +Description: support for Rendering information + +Feature: namespace +Description: Build with the WITH_CPP_NAMESPACE option set to on diff --git a/ports/libsbml/fix-linkage-type.patch b/ports/libsbml/fix-linkage-type.patch new file mode 100644 index 00000000000..08186357ad3 --- /dev/null +++ b/ports/libsbml/fix-linkage-type.patch @@ -0,0 +1,22 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index eb692cf..11158db 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -524,7 +524,7 @@ INSTALL( + endif() + + +-endif() ++else() + + add_library (${LIBSBML_LIBRARY}-static STATIC ${LIBSBML_SOURCES} ) + +@@ -560,7 +560,7 @@ INSTALL(FILES + DESTINATION ${PACKAGE_CONFIG_DIR} + ) + endif() +- ++endif() + ############################################################################## + # + # add native tests diff --git a/ports/libsbml/portfile.cmake b/ports/libsbml/portfile.cmake new file mode 100644 index 00000000000..ed7749daa97 --- /dev/null +++ b/ports/libsbml/portfile.cmake @@ -0,0 +1,83 @@ +vcpkg_download_distfile(ARCHIVE + URLS "https://sourceforge.net/projects/sbml/files/libsbml/5.18.0/stable/libSBML-5.18.0-core-plus-packages-src.tar.gz/download" + FILENAME "libSBML-5.18.0.zip" + SHA512 49dedaa2fcd2077e7389a8f940adf931d80aa7a8f9d57330328372d2ac8ebcaeb03a20524df2fe0f1c6933587904613754585076c46e6cb5d6f7a001f427185b +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + PATCHES fix-linkage-type.patch +) + +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" STATIC_RUNTIME) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" STATIC_LIBRARY) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + comp ENABLE_COMP + fbc ENABLE_FBC + groups ENABLE_GROUPS + layout ENABLE_LAYOUT + multi ENABLE_MULTI + qual ENABLE_QUAL + render ENABLE_RENDER + render ENABLE_LAYOUT + bzip2 WITH_BZIP2 + zlib WITH_ZLIB + test WITH_CHECK + namespace WITH_CPP_NAMESPACE +) + +# Handle conflict features +set(WITH_EXPAT OFF) +if ("expat" IN_LIST FEATURES) + set(WITH_EXPAT ON) +endif() + +set(WITH_LIBXML OFF) +if ("libxml2" IN_LIST FEATURES) + set(WITH_LIBXML ON) +endif() + +if (WITH_EXPAT AND WITH_LIBXML) + message("Feature expat conflict with feature libxml2, currently using libxml2...") + set(WITH_EXPAT OFF) +endif() + +if ("test" IN_LIST FEATURES AND WIN32) + message(FATAL_ERROR "Feature test only support UNIX.") +endif() + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA # Disable this option if project cannot be built with Ninja + OPTIONS ${FEATURE_OPTIONS} + -DWITH_EXPAT=${WITH_EXPAT} + -DWITH_LIBXML=${WITH_LIBXML} + -DENABLE_L3V2EXTENDEDMATH:BOOL=ON + -DWITH_STATIC_RUNTIME=${STATIC_RUNTIME} + -DLIBSBML_SKIP_SHARED_LIBRARY=${STATIC_LIBRARY} +) + +vcpkg_install_cmake() + +vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake) + +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +file(GLOB TXT_FILES ${CURRENT_PACKAGES_DIR}/debug/*.txt) +if (TXT_FILES) + file(REMOVE ${TXT_FILES}) +endif() +file(GLOB TXT_FILES ${CURRENT_PACKAGES_DIR}/*.txt) +if (TXT_FILES) + file(REMOVE ${TXT_FILES}) +endif() + +if (EXISTS ${CURRENT_PACKAGES_DIR}/debug/share) + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) +endif() + +file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) \ No newline at end of file