From 67cd68d6f0ee0706ef740af8e4a8ace6194635a4 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Mon, 19 Aug 2024 18:58:36 +0200 Subject: [PATCH] [libcerf] Update and fix (#40423) --- ports/libcerf/001-fix-static-build.patch | 13 ------- ports/libcerf/begin-end-decls.diff | 44 +++++++++++++++++++++++ ports/libcerf/cxx-flags.diff | 22 ++++++++++++ ports/libcerf/fix-source.diff | 26 ++++++++++++++ ports/libcerf/install-dirs.diff | 13 +++++++ ports/libcerf/portfile.cmake | 45 +++++++++++------------- ports/libcerf/vcpkg.json | 7 ++-- scripts/ci.baseline.txt | 1 - versions/baseline.json | 4 +-- versions/l-/libcerf.json | 5 +++ 10 files changed, 137 insertions(+), 43 deletions(-) delete mode 100644 ports/libcerf/001-fix-static-build.patch create mode 100644 ports/libcerf/begin-end-decls.diff create mode 100644 ports/libcerf/cxx-flags.diff create mode 100644 ports/libcerf/fix-source.diff create mode 100644 ports/libcerf/install-dirs.diff diff --git a/ports/libcerf/001-fix-static-build.patch b/ports/libcerf/001-fix-static-build.patch deleted file mode 100644 index ffaeaedfbf..0000000000 --- a/ports/libcerf/001-fix-static-build.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index f79581f..4fc9457 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -56,6 +56,8 @@ if(MSVC) - # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/$) - if(BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -+ else() -+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") - endif() - else() - add_compile_options(-O2 -Wno-sign-compare -fno-omit-frame-pointer) diff --git a/ports/libcerf/begin-end-decls.diff b/ports/libcerf/begin-end-decls.diff new file mode 100644 index 0000000000..151d056b92 --- /dev/null +++ b/ports/libcerf/begin-end-decls.diff @@ -0,0 +1,44 @@ +diff --git a/lib/cerf.h b/lib/cerf.h +index 28576ab..c9bc6dd 100644 +--- a/lib/cerf.h ++++ b/lib/cerf.h +@@ -55,25 +55,23 @@ + typedef double _Complex _cerf_cmplx; + # endif + +-# undef __BEGIN_DECLS +-# undef __END_DECLS + # ifdef CERF_AS_CPP + # ifndef __cplusplus + impossible_case + # endif +-# define __BEGIN_DECLS +-# define __END_DECLS ++# define LIBCERF_BEGIN_DECLS ++# define LIBCERF_END_DECLS + # else + # ifdef __cplusplus // this include file called from C++ while library is compiled as C +-# define __BEGIN_DECLS extern "C" { +-# define __END_DECLS } ++# define LIBCERF_BEGIN_DECLS extern "C" { ++# define LIBCERF_END_DECLS } + # else +-# define __BEGIN_DECLS +-# define __END_DECLS ++# define LIBCERF_BEGIN_DECLS ++# define LIBCERF_END_DECLS + # endif + # endif + +-__BEGIN_DECLS ++LIBCERF_BEGIN_DECLS + + #if _WIN32 + #define EXPORT __declspec(dllexport) +@@ -111,5 +109,5 @@ EXPORT double voigt(double x, double sigma, double gamma); + // compute the full width at half maximum of the Voigt function + EXPORT double voigt_hwhm(double sigma, double gamma); + +-__END_DECLS ++LIBCERF_END_DECLS + #endif /* __CERF_H__ */ diff --git a/ports/libcerf/cxx-flags.diff b/ports/libcerf/cxx-flags.diff new file mode 100644 index 0000000000..f571764d53 --- /dev/null +++ b/ports/libcerf/cxx-flags.diff @@ -0,0 +1,22 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e33ce56..f037190 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -45,16 +45,12 @@ if(MSVC) + message(FATAL_ERROR "Under MSVC, only CERF_CPP=ON is supported") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # parallel compilation +- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS}") + set(MS_NOWARN "/wd4018 /wd4068 /wd4101 /wd4244 /wd4267 /wd4305 /wd4715 /wd4996") + set(MS_D "-D_CRT_SECURE_NO_WARNINGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING") +- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${MS_NOWARN} ${MS_D}") ++ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MS_NOWARN} ${MS_D}") + set(CTEST_CONFIGURATION_TYPE "${JOB_BUILD_CONFIGURATION}") + if(BUILD_SHARED_LIBS) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +- else() +- # required for post-build validation under vcpkg: +- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") # multithreaded, debug + endif() + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/ports/libcerf/fix-source.diff b/ports/libcerf/fix-source.diff new file mode 100644 index 0000000000..9b6f82cb5b --- /dev/null +++ b/ports/libcerf/fix-source.diff @@ -0,0 +1,26 @@ +diff --git a/lib/width.c b/lib/width.c +index 37c3afa..b4b6bda 100644 +--- a/lib/width.c ++++ b/lib/width.c +@@ -47,7 +47,7 @@ using std::isnan; + * Olivero & Longbothum [1977] + * Journal of Quantitative Spectroscopy and Radiative Transfer. 17:233 + */ +-double hwhm0(double sigma, double gamma) ++static double hwhm0(double sigma, double gamma) + { + return .5*(1.06868*gamma+sqrt(0.86743*gamma*gamma+4*2*log(2)*sigma*sigma)); + } +diff --git a/test/widthtest.c b/test/widthtest.c +index b395d34..a44b83f 100644 +--- a/test/widthtest.c ++++ b/test/widthtest.c +@@ -28,7 +28,7 @@ + #include "testtool.h" + + // excellent approximation [Olivero & Longbothum, 1977], used as starting value in voigt_hwhm +-double hwhm0(double sigma, double gamma) ++static double hwhm0(double sigma, double gamma) + { + return .5*(1.06868*gamma+sqrt(0.86743*gamma*gamma+4*2*log(2)*sigma*sigma)); + } diff --git a/ports/libcerf/install-dirs.diff b/ports/libcerf/install-dirs.diff new file mode 100644 index 0000000000..81e4c766c3 --- /dev/null +++ b/ports/libcerf/install-dirs.diff @@ -0,0 +1,13 @@ +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index 0a54d5d..e69a984 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -38,7 +38,7 @@ target_include_directories(${lib} INTERFACE + install( + TARGETS ${lib} + EXPORT ${intf} +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT Libraries) diff --git a/ports/libcerf/portfile.cmake b/ports/libcerf/portfile.cmake index d3b5280fc7..671562e625 100644 --- a/ports/libcerf/portfile.cmake +++ b/ports/libcerf/portfile.cmake @@ -1,37 +1,32 @@ -if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - set(BUILD_SHARED_LIBS ON) -else() - set(BUILD_SHARED_LIBS OFF) -endif() - -vcpkg_download_distfile(ARCHIVE - URLS "https://jugit.fz-juelich.de/mlz/libcerf/uploads/924b8d245ad3461107ec630734dfc781/libcerf-1.13.tgz" - FILENAME "libcerf-1.13.tgz" - SHA512 4df711d3e9fd00de99959c3253a9565d1dc2c41f75a5800ced9c52f89cbd13185fbdca3ad75de788fd16c044082738ab345b7fb6a8820ac588edafe1812944aa +vcpkg_from_gitlab( + OUT_SOURCE_PATH SOURCE_PATH + GITLAB_URL https://jugit.fz-juelich.de + REPO mlz/libcerf + REF "v${VERSION}" + SHA512 0e78a18c498705d5efa26e504932192c4d49485cc3f971235c86c4dc6ca7498063f33e188a55f4c939e25d0d2a2f215b22ef11d3776d80a4a7486ea62fad1d73 + PATCHES + cxx-flags.diff + fix-source.diff + begin-end-decls.diff + install-dirs.diff ) -vcpkg_extract_source_archive( - SOURCE_PATH - ARCHIVE ${ARCHIVE} - PATCHES 001-fix-static-build.patch -) - -if(VCPKG_TARGET_IS_UWP) - set(configure_opts WINDOWS_USE_MSBUILD) -endif() - vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" - ${configure_opts} OPTIONS -DCERF_CPP=ON -DLIB_MAN=OFF - -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} + -DLIB_RUN=OFF ) vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/cerf PACKAGE_NAME cerf) +vcpkg_fixup_pkgconfig() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/cerf.h" "dllexport" "dllimport") +endif() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/libcerf" RENAME copyright) - -vcpkg_fixup_pkgconfig() + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/ports/libcerf/vcpkg.json b/ports/libcerf/vcpkg.json index eed2bb6ccd..de42e09c4b 100644 --- a/ports/libcerf/vcpkg.json +++ b/ports/libcerf/vcpkg.json @@ -1,13 +1,16 @@ { "name": "libcerf", - "version": "1.13", - "port-version": 4, + "version": "2.4", "description": "A self-contained numeric library that provides an efficient and accurate implementation of complex error functions, along with Dawson, Faddeeva, and Voigt functions.", "homepage": "https://jugit.fz-juelich.de/mlz/libcerf", "dependencies": [ { "name": "vcpkg-cmake", "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true } ] } diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 92df31435c..1030e84eaa 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -527,7 +527,6 @@ libcaer:x64-android=fail libcanberra:arm-neon-android=fail libcanberra:arm64-android=fail libcanberra:x64-android=fail -libcerf:x64-windows-static-md=fail # needs android-24 libconfuse:arm-neon-android=fail libconfuse:arm64-android=fail diff --git a/versions/baseline.json b/versions/baseline.json index ea033dd074..d45a29a762 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4293,8 +4293,8 @@ "port-version": 4 }, "libcerf": { - "baseline": "1.13", - "port-version": 4 + "baseline": "2.4", + "port-version": 0 }, "libcgroup": { "baseline": "3.1.0", diff --git a/versions/l-/libcerf.json b/versions/l-/libcerf.json index 012d99e04e..04ade16710 100644 --- a/versions/l-/libcerf.json +++ b/versions/l-/libcerf.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "f2f77d2b2c3bc81887b4a6a3f398acc42e4e59d0", + "version": "2.4", + "port-version": 0 + }, { "git-tree": "7d9138bfd878a5de79822e201b0e83649715121c", "version": "1.13",