mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 01:57:17 +08:00
[libmodbus] Fix static linkage error (#12530)
This commit is contained in:
parent
4da29fee9d
commit
ef037af3d7
@ -59,9 +59,10 @@ configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_compile_options(-DDLLBUILD=ON)
|
||||
else()
|
||||
add_compile_options(-DLIBBUILD=ON)
|
||||
endif()
|
||||
|
||||
|
||||
set(MODBUS_PUBLIC_HEADERS
|
||||
src/modbus-rtu.h
|
||||
src/modbus-tcp.h
|
||||
|
@ -1,3 +0,0 @@
|
||||
Source: libmodbus
|
||||
Version: 3.1.6
|
||||
Description: libmodbus is a free software library to send/receive data with a device which respects the Modbus protocol
|
13
ports/libmodbus/fix-static-linkage.patch
Normal file
13
ports/libmodbus/fix-static-linkage.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/src/modbus.h b/src/modbus.h
|
||||
index fbe20bc..895d05d 100644
|
||||
--- a/src/modbus.h
|
||||
+++ b/src/modbus.h
|
||||
@@ -24,6 +24,8 @@
|
||||
# if defined(DLLBUILD)
|
||||
/* define DLLBUILD when building the DLL */
|
||||
# define MODBUS_API __declspec(dllexport)
|
||||
+# elif defined(LIBBUILD)
|
||||
+# define MODBUS_API
|
||||
# else
|
||||
# define MODBUS_API __declspec(dllimport)
|
||||
# endif
|
@ -1,27 +1,32 @@
|
||||
include(vcpkg_common_functions)
|
||||
vcpkg_fail_port_install(ON_TARGET "uwp")
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO stephane/libmodbus
|
||||
REF v3.1.6
|
||||
SHA512 9eaa395c75e1170e703e01f8c52c6e6e87efe4eaa22adfc3b51153fd5535d545aea35cf68e1aba29720a6c1dd13d9c60b6b08a5c8098dccd13ccfdc6944420a9
|
||||
HEAD_REF master
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO stephane/libmodbus
|
||||
REF v3.1.6
|
||||
SHA512 9eaa395c75e1170e703e01f8c52c6e6e87efe4eaa22adfc3b51153fd5535d545aea35cf68e1aba29720a6c1dd13d9c60b6b08a5c8098dccd13ccfdc6944420a9
|
||||
HEAD_REF master
|
||||
PATCHES fix-static-linkage.patch
|
||||
)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt ${CMAKE_CURRENT_LIST_DIR}/config.h.cmake DESTINATION ${SOURCE_PATH})
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
PREFER_NINJA
|
||||
OPTIONS_DEBUG
|
||||
-DDISABLE_INSTALL_HEADERS=ON
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
PREFER_NINJA
|
||||
OPTIONS_DEBUG
|
||||
-DDISABLE_INSTALL_HEADERS=ON
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
vcpkg_copy_pdbs()
|
||||
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake)
|
||||
|
||||
# Handle copyright
|
||||
file(INSTALL ${SOURCE_PATH}/COPYING.LESSER DESTINATION ${CURRENT_PACKAGES_DIR}/share/libmodbus RENAME copyright)
|
||||
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/modbus.h "elif defined(LIBBUILD)" "elif 1")
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
# Handle copyright
|
||||
file(INSTALL ${SOURCE_PATH}/COPYING.LESSER DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
8
ports/libmodbus/vcpkg.json
Normal file
8
ports/libmodbus/vcpkg.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "libmodbus",
|
||||
"version-string": "3.1.6",
|
||||
"port-version": 1,
|
||||
"description": "libmodbus is a free software library to send/receive data with a device which respects the Modbus protocol",
|
||||
"homepage": "https://github.com/stephane/libmodbus",
|
||||
"supports": "!uwp"
|
||||
}
|
@ -773,8 +773,6 @@ libmesh:x64-windows-static=skip
|
||||
libmesh:x86-windows=skip
|
||||
libmesh:x64-osx=skip
|
||||
libmesh:x64-linux=skip
|
||||
libmodbus:arm-uwp=fail
|
||||
libmodbus:x64-uwp=fail
|
||||
libmodman:arm-uwp=fail
|
||||
libmodman:x64-uwp=fail
|
||||
libmodman:x64-windows-static=fail
|
||||
|
Loading…
x
Reference in New Issue
Block a user