mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 10:21:07 +08:00
[rhash] Fix error, revise dllexport/dllimport (#36950)
Pass `RHASH_XVERSION` as a number number, not as a string. General error, but detected by Android NDK r26 ~~~ vcpkg/buildtrees/rhash/src/v1.4.4-e609ae2b07.clean/librhash/rhash.c:877:10: error: incompatible pointer to integer conversion returning 'char[1]' from a function with result type 'rhash_uptr_t' (aka 'unsigned int') [-Wint-conversion] return RHASH_XVERSION; ^~~~~~~~~~~~~~ <command line>:2:24: note: expanded from macro 'RHASH_XVERSION' #define RHASH_XVERSION "" ^~ 1 error generated. ~~~ Complement `dllexport` with `dllimport` for shared windows, and omit it everywhere else. Add missing pc file as if installed with official build system.
This commit is contained in:
parent
a6bb03dedf
commit
ea91673467
@ -1,12 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(rhash C)
|
||||
|
||||
# cf. configure: RHASH_XVERSION = $(printf "0x%02x%02x%02x%02x" "$_v1" "$_v2" "$_v3" 0)
|
||||
set(RHASH_VERSION "undefined" CACHE STRING "")
|
||||
if(NOT RHASH_VERSION MATCHES [[^([0-9]+)[.]([0-9]+)[.]([0-9]+)$]])
|
||||
message(FATAL_ERROR "Cannot derive RHASH_XVERSION from '${RHASH_VERSION}'")
|
||||
endif()
|
||||
MATH(EXPR RHASH_XVERSION "((${CMAKE_MATCH_1} * 256 + ${CMAKE_MATCH_2}) * 256 + ${CMAKE_MATCH_3}) * 256" OUTPUT_FORMAT HEXADECIMAL)
|
||||
|
||||
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/Makefile RHASH_SOURCES REGEX "^SOURCES = .*$")
|
||||
string(REPLACE "SOURCES = " "" RHASH_SOURCES "${RHASH_SOURCES}")
|
||||
string(REPLACE " " ";" RHASH_SOURCES "${RHASH_SOURCES}")
|
||||
add_definitions(-DRHASH_XVERSION="${RHASH_XVERSION}")
|
||||
|
||||
add_library(rhash ${RHASH_SOURCES})
|
||||
set_target_properties(rhash PROPERTIES COMPILE_DEFINITIONS "IN_RHASH" DEFINE_SYMBOL "RHASH_EXPORTS")
|
||||
|
||||
target_compile_definitions(rhash PRIVATE RHASH_XVERSION=${RHASH_XVERSION})
|
||||
|
||||
if(WIN32 AND BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(rhash PRIVATE RHASH_EXPORTS)
|
||||
endif()
|
||||
|
||||
target_include_directories(rhash INTERFACE $<INSTALL_INTERFACE:include>)
|
||||
|
||||
@ -25,3 +37,20 @@ install(EXPORT unofficial-rhash-config
|
||||
if(NOT RHASH_SKIP_HEADERS)
|
||||
install(FILES rhash.h rhash_torrent.h DESTINATION include)
|
||||
endif()
|
||||
|
||||
# cf. configure
|
||||
set(LIBRHASH_PC "${CMAKE_CURRENT_BINARY_DIR}/librhash.pc")
|
||||
file(WRITE "${LIBRHASH_PC}"
|
||||
"prefix=fixup
|
||||
exec_prefix=\${prefix}
|
||||
libdir=\${prefix}/lib
|
||||
includedir=\${prefix}/include
|
||||
|
||||
Name: librash
|
||||
Description: LibRHash shared library
|
||||
Version: ${RHASH_VERSION}
|
||||
Cflags: -I\${includedir}
|
||||
Libs: -L\${libdir} -lrhash
|
||||
")
|
||||
|
||||
install(FILES "${LIBRHASH_PC}" DESTINATION "lib/pkgconfig")
|
||||
|
@ -1,4 +1,3 @@
|
||||
set(RHASH_XVERSION 1.4.2)
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO rhash/RHash
|
||||
@ -11,6 +10,8 @@ file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}/librhash"
|
||||
OPTIONS
|
||||
-DRHASH_VERSION=${VERSION}
|
||||
OPTIONS_DEBUG
|
||||
-DRHASH_SKIP_HEADERS=ON
|
||||
)
|
||||
@ -18,5 +19,10 @@ vcpkg_cmake_configure(
|
||||
vcpkg_cmake_install()
|
||||
vcpkg_copy_pdbs()
|
||||
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-rhash)
|
||||
vcpkg_fixup_pkgconfig()
|
||||
|
||||
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
||||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/rhash.h" "# define RHASH_API" "# define RHASH_API __declspec(dllimport)")
|
||||
endif()
|
||||
|
||||
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "rhash",
|
||||
"version": "1.4.4",
|
||||
"port-version": 1,
|
||||
"description": "C library for computing a wide variety of hash sums",
|
||||
"homepage": "https://github.com/rhash/RHash",
|
||||
"license": "0BSD",
|
||||
|
@ -7590,7 +7590,7 @@
|
||||
},
|
||||
"rhash": {
|
||||
"baseline": "1.4.4",
|
||||
"port-version": 0
|
||||
"port-version": 1
|
||||
},
|
||||
"rhasheq": {
|
||||
"baseline": "2023-06-17",
|
||||
|
@ -1,5 +1,10 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "a3e224c21215bd63a0404550b6b396254a60635e",
|
||||
"version": "1.4.4",
|
||||
"port-version": 1
|
||||
},
|
||||
{
|
||||
"git-tree": "cb7e94fe8d5d109574fd0e304e246c780f0b43c5",
|
||||
"version": "1.4.4",
|
||||
|
Loading…
x
Reference in New Issue
Block a user