[libtommath] Install pc file, cleanup (#51362)

This commit is contained in:
Kai Pastor 2026-04-24 22:49:30 +02:00 committed by GitHub
parent 5a39b682d4
commit 0e011d3934
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 41 additions and 26 deletions

View File

@ -1,8 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b5c73c..77ca1f5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,8 +22,10 @@
#-----------------------------------------------------------------------------
@@ -23,6 +23,8 @@ set(PACKAGE_RELEASE_VERSION 1)
include(GNUInstallDirs)
include(CheckIPOSupported)
include(CMakePackageConfigHelpers)
@ -11,32 +11,30 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt
# default is "No tests"
option(BUILD_TESTING "" OFF)
include(CTest)
include(sources.cmake)
@@ -118,8 +120,19 @@
target_link_options(${PROJECT_NAME} BEFORE PRIVATE
@@ -119,6 +121,18 @@ target_link_options(${PROJECT_NAME} BEFORE PRIVATE
${LTM_LD_FLAGS}
)
+if(MSVC)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_LIBRARIES bcrypt)
+ check_symbol_exists(BCryptGenRandom "Windows.h;bcrypt.h" BCRYPT_AVAILABLE)
+ check_symbol_exists(BCryptGenRandom "windows.h;bcrypt.h" BCRYPT_AVAILABLE)
+ cmake_pop_check_state()
+ if(BCRYPT_AVAILABLE)
+ target_compile_definitions(${PROJECT_NAME} PRIVATE LTM_WIN32_BCRYPT)
+ target_link_libraries(${PROJECT_NAME} PRIVATE bcrypt)
+ string(APPEND PC_LIBS_PRIVATE -lbcrypt)
+ endif()
+endif()
+
set(PUBLIC_HEADERS tommath.h)
set(C89 False CACHE BOOL "(Usually maintained automatically) Enable when the library is in c89 mode to package the correct header files on install")
if(C89)
list(APPEND PUBLIC_HEADERS tommath_c89.h)
diff --git a/bn_s_mp_rand_platform.c b/bn_s_mp_rand_platform.c
index 27339bf..097f7be 100644
--- a/bn_s_mp_rand_platform.c
+++ b/bn_s_mp_rand_platform.c
@@ -28,8 +28,19 @@
#endif
@@ -29,6 +29,17 @@ static mp_err s_read_arc4random(void *p, size_t n)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -54,9 +52,7 @@ diff --git a/bn_s_mp_rand_platform.c b/bn_s_mp_rand_platform.c
#include <wincrypt.h>
static mp_err s_read_wincsp(void *p, size_t n)
{
@@ -45,8 +56,9 @@
hProv = h;
@@ -46,6 +57,7 @@ static mp_err s_read_wincsp(void *p, size_t n)
}
return CryptGenRandom(hProv, (DWORD)n, (BYTE *)p) == TRUE ? MP_OKAY : MP_ERR;
}
@ -64,4 +60,13 @@ diff --git a/bn_s_mp_rand_platform.c b/bn_s_mp_rand_platform.c
#endif /* WIN32 */
#if !defined(BN_S_READ_WINCSP_C) && defined(__linux__) && defined(__GLIBC_PREREQ)
#if __GLIBC_PREREQ(2, 25)
diff --git a/libtommath.pc.in b/libtommath.pc.in
index 7ce50fd..4b8e5fa 100644
--- a/libtommath.pc.in
+++ b/libtommath.pc.in
@@ -6,4 +6,5 @@ Name: LibTomMath
Description: public domain library for manipulating large integer numbers
Version: @PROJECT_VERSION@
Libs: -L${libdir} -ltommath
+Libs.private: @PC_LIBS_PRIVATE@
Cflags: -I${includedir}

View File

@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0b84e79..6b5c73c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -168,7 +168,7 @@ install(TARGETS ${PROJECT_NAME}
)
# Install libtommath.pc for pkg-config if we build a shared library
-if(BUILD_SHARED_LIBS)
+if(1)
# Let the user override the default directory of the pkg-config file (usually this shouldn't be required to be changed)
set(CMAKE_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" CACHE PATH "Folder where to install .pc files")

View File

@ -5,6 +5,7 @@ vcpkg_from_github(
SHA512 3dbd7053a670afa563a069a9785f1aa4cab14a210bcd05d8fc7db25bd3dcce36b10a3f4f54ca92d75a694f891226f01bdf6ac15bacafeb93a8be6b04c579beb3
HEAD_REF develop
PATCHES
pkgconfig.diff
bcrypt.patch
import-lib.patch
has-set-double.patch # Remove in next release.
@ -18,8 +19,8 @@ vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}")
vcpkg_fixup_pkgconfig()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

View File

@ -1,9 +0,0 @@
libtommath provides CMake targets:
find_package(libtommath CONFIG REQUIRED)
target_link_libraries(main PRIVATE libtommath)
libtommath provides pkg-config modules:
# public domain library for manipulating large integer numbers
libtommath

View File

@ -1,7 +1,7 @@
{
"name": "libtommath",
"version": "1.3.0",
"port-version": 2,
"port-version": 3,
"description": "LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C.",
"homepage": "https://www.libtom.net/LibTomMath/",
"dependencies": [

View File

@ -5718,7 +5718,7 @@
},
"libtommath": {
"baseline": "1.3.0",
"port-version": 2
"port-version": 3
},
"libtorch": {
"baseline": "2.7.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "8c4b429fb5503880f905636d43045d9314be4a42",
"version": "1.3.0",
"port-version": 3
},
{
"git-tree": "22eed88d2b6d6ed3b4534de9bf87900e67050394",
"version": "1.3.0",