diff options
| author | NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> | 2020-07-31 13:57:28 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-30 22:57:28 -0700 |
| commit | ef037af3d73d9843d22a298f01504510b76f200f (patch) | |
| tree | b119dd97db2d9f23074bd248e877e174ac96184f | |
| parent | 4da29fee9db506bc68c46108a4e9379ea0d8f431 (diff) | |
| download | vcpkg-ef037af3d73d9843d22a298f01504510b76f200f.tar.gz vcpkg-ef037af3d73d9843d22a298f01504510b76f200f.zip | |
[libmodbus] Fix static linkage error (#12530)
| -rw-r--r-- | ports/libmodbus/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | ports/libmodbus/CONTROL | 3 | ||||
| -rw-r--r-- | ports/libmodbus/fix-static-linkage.patch | 13 | ||||
| -rw-r--r-- | ports/libmodbus/portfile.cmake | 29 | ||||
| -rw-r--r-- | ports/libmodbus/vcpkg.json | 8 | ||||
| -rw-r--r-- | scripts/ci.baseline.txt | 2 |
6 files changed, 40 insertions, 18 deletions
diff --git a/ports/libmodbus/CMakeLists.txt b/ports/libmodbus/CMakeLists.txt index c08abe838..618ba5f6c 100644 --- a/ports/libmodbus/CMakeLists.txt +++ b/ports/libmodbus/CMakeLists.txt @@ -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
diff --git a/ports/libmodbus/CONTROL b/ports/libmodbus/CONTROL deleted file mode 100644 index cb3f5a295..000000000 --- a/ports/libmodbus/CONTROL +++ /dev/null @@ -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
diff --git a/ports/libmodbus/fix-static-linkage.patch b/ports/libmodbus/fix-static-linkage.patch new file mode 100644 index 000000000..7d7ae79f5 --- /dev/null +++ b/ports/libmodbus/fix-static-linkage.patch @@ -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 diff --git a/ports/libmodbus/portfile.cmake b/ports/libmodbus/portfile.cmake index fda250e4f..a607f5a9e 100644 --- a/ports/libmodbus/portfile.cmake +++ b/ports/libmodbus/portfile.cmake @@ -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)
+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()
+
# Handle copyright
-file(INSTALL ${SOURCE_PATH}/COPYING.LESSER DESTINATION ${CURRENT_PACKAGES_DIR}/share/libmodbus RENAME copyright)
+file(INSTALL ${SOURCE_PATH}/COPYING.LESSER DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
-file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
+file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
\ No newline at end of file diff --git a/ports/libmodbus/vcpkg.json b/ports/libmodbus/vcpkg.json new file mode 100644 index 000000000..cea788931 --- /dev/null +++ b/ports/libmodbus/vcpkg.json @@ -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" +} diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index e63835f54..f33d3513b 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -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 |
