[libcerf] Update and fix (#40423)

This commit is contained in:
Kai Pastor 2024-08-19 18:58:36 +02:00 committed by GitHub
parent 5f307bfca6
commit 67cd68d6f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 137 additions and 43 deletions

View File

@ -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/$<CONFIG>)
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)

View File

@ -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__ */

View File

@ -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})

View File

@ -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));
}

View File

@ -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)

View File

@ -1,37 +1,32 @@
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) vcpkg_from_gitlab(
set(BUILD_SHARED_LIBS ON) OUT_SOURCE_PATH SOURCE_PATH
else() GITLAB_URL https://jugit.fz-juelich.de
set(BUILD_SHARED_LIBS OFF) REPO mlz/libcerf
endif() REF "v${VERSION}"
SHA512 0e78a18c498705d5efa26e504932192c4d49485cc3f971235c86c4dc6ca7498063f33e188a55f4c939e25d0d2a2f215b22ef11d3776d80a4a7486ea62fad1d73
vcpkg_download_distfile(ARCHIVE PATCHES
URLS "https://jugit.fz-juelich.de/mlz/libcerf/uploads/924b8d245ad3461107ec630734dfc781/libcerf-1.13.tgz" cxx-flags.diff
FILENAME "libcerf-1.13.tgz" fix-source.diff
SHA512 4df711d3e9fd00de99959c3253a9565d1dc2c41f75a5800ced9c52f89cbd13185fbdca3ad75de788fd16c044082738ab345b7fb6a8820ac588edafe1812944aa 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( vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}" SOURCE_PATH "${SOURCE_PATH}"
${configure_opts}
OPTIONS OPTIONS
-DCERF_CPP=ON -DCERF_CPP=ON
-DLIB_MAN=OFF -DLIB_MAN=OFF
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DLIB_RUN=OFF
) )
vcpkg_cmake_install() 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(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/libcerf" RENAME copyright)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
vcpkg_fixup_pkgconfig()

View File

@ -1,13 +1,16 @@
{ {
"name": "libcerf", "name": "libcerf",
"version": "1.13", "version": "2.4",
"port-version": 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.", "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", "homepage": "https://jugit.fz-juelich.de/mlz/libcerf",
"dependencies": [ "dependencies": [
{ {
"name": "vcpkg-cmake", "name": "vcpkg-cmake",
"host": true "host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
} }
] ]
} }

View File

@ -527,7 +527,6 @@ libcaer:x64-android=fail
libcanberra:arm-neon-android=fail libcanberra:arm-neon-android=fail
libcanberra:arm64-android=fail libcanberra:arm64-android=fail
libcanberra:x64-android=fail libcanberra:x64-android=fail
libcerf:x64-windows-static-md=fail
# needs android-24 # needs android-24
libconfuse:arm-neon-android=fail libconfuse:arm-neon-android=fail
libconfuse:arm64-android=fail libconfuse:arm64-android=fail

View File

@ -4293,8 +4293,8 @@
"port-version": 4 "port-version": 4
}, },
"libcerf": { "libcerf": {
"baseline": "1.13", "baseline": "2.4",
"port-version": 4 "port-version": 0
}, },
"libcgroup": { "libcgroup": {
"baseline": "3.1.0", "baseline": "3.1.0",

View File

@ -1,5 +1,10 @@
{ {
"versions": [ "versions": [
{
"git-tree": "f2f77d2b2c3bc81887b4a6a3f398acc42e4e59d0",
"version": "2.4",
"port-version": 0
},
{ {
"git-tree": "7d9138bfd878a5de79822e201b0e83649715121c", "git-tree": "7d9138bfd878a5de79822e201b0e83649715121c",
"version": "1.13", "version": "1.13",