diff options
| author | Phoebe <20694052+PhoebeHui@users.noreply.github.com> | 2021-01-05 12:42:29 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-05 12:42:29 -0800 |
| commit | 1aba77ae3b0f766eeea91888f4c4fa082e16d9ea (patch) | |
| tree | 02af7520d220cc43af7675f893a114b471cb336b | |
| parent | c1e9424206e0c52e98efbc28d3c75836e02bb5f3 (diff) | |
| download | vcpkg-1aba77ae3b0f766eeea91888f4c4fa082e16d9ea.tar.gz vcpkg-1aba77ae3b0f766eeea91888f4c4fa082e16d9ea.zip | |
[hidapi] Support static build (#15437)
* [hidapi] Support static build
* Update portfile.cmake
| -rw-r--r-- | ports/hidapi/CONTROL | 4 | ||||
| -rw-r--r-- | ports/hidapi/portfile.cmake | 50 | ||||
| -rw-r--r-- | ports/hidapi/vcpkg.json | 8 |
3 files changed, 44 insertions, 18 deletions
diff --git a/ports/hidapi/CONTROL b/ports/hidapi/CONTROL deleted file mode 100644 index 80f18b493..000000000 --- a/ports/hidapi/CONTROL +++ /dev/null @@ -1,4 +0,0 @@ -Source: hidapi
-Version: 2019-08-30
-Description: A Simple library for communicating with USB and Bluetooth HID devices on Linux, Mac and Windows.
-Homepage: https://github.com/libusb/hidapi
diff --git a/ports/hidapi/portfile.cmake b/ports/hidapi/portfile.cmake index ec7abb495..ea2cd092b 100644 --- a/ports/hidapi/portfile.cmake +++ b/ports/hidapi/portfile.cmake @@ -1,3 +1,5 @@ +vcpkg_fail_port_install(ON_ARCH "arm" "arm64" ON_TARGET "linux" "osx" "uwp")
+
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO libusb/hidapi
@@ -7,26 +9,46 @@ vcpkg_from_github( )
if(VCPKG_TARGET_IS_WINDOWS)
- if(TRIPLET_SYSTEM_ARCH MATCHES "arm")
- message(FATAL_ERROR "ARM builds are currently not supported!")
- elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
- message(FATAL_ERROR "UWP builds are currently not supported!")
+ file(READ "${SOURCE_PATH}/windows/hidapi.vcxproj" _contents)
+ if(${VCPKG_CRT_LINKAGE} STREQUAL "dynamic")
+ string(REGEX REPLACE
+ "<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>"
+ "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>"
+ _contents "${_contents}")
+ string(REGEX REPLACE
+ "<RuntimeLibrary>MultiThreaded</RuntimeLibrary>"
+ "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>"
+ _contents "${_contents}")
+ else()
+ string(REGEX REPLACE
+ "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>"
+ "<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>"
+ _contents "${_contents}")
+ string(REGEX REPLACE
+ "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>"
+ "<RuntimeLibrary>MultiThreaded</RuntimeLibrary>"
+ _contents "${_contents}")
+ endif()
+
+ if(${VCPKG_LIBRARY_LINKAGE} STREQUAL "dynamic")
+ string(REPLACE
+ "<ConfigurationType>StaticLibrary</ConfigurationType>"
+ "<ConfigurationType>DynamicLibrary</ConfigurationType>"
+ _contents "${_contents}")
+ else()
+ string(REPLACE
+ "<ConfigurationType>DynamicLibrary</ConfigurationType>"
+ "<ConfigurationType>StaticLibrary</ConfigurationType>"
+ _contents "${_contents}")
endif()
+ file(WRITE "${SOURCE_PATH}/windows/hidapi.vcxproj" "${_contents}")
vcpkg_install_msbuild(
SOURCE_PATH ${SOURCE_PATH}
- PROJECT_SUBPATH windows/hidapi.sln
+ PROJECT_SUBPATH windows/hidapi.vcxproj
INCLUDES_SUBPATH hidapi ALLOW_ROOT_INCLUDES
LICENSE_SUBPATH LICENSE-bsd.txt # use BSD license
)
- file(COPY
- ${CMAKE_CURRENT_LIST_DIR}/hidapi-config.cmake
- DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
-
- if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
- file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
- endif()
-else()
- message(FATAL_ERROR "Non-Windows builds are currently not supported!")
+ file(COPY ${CMAKE_CURRENT_LIST_DIR}/hidapi-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
endif()
diff --git a/ports/hidapi/vcpkg.json b/ports/hidapi/vcpkg.json new file mode 100644 index 000000000..f73f97f2e --- /dev/null +++ b/ports/hidapi/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "hidapi", + "version-string": "2019-08-30", + "port-version": 1, + "description": "A Simple library for communicating with USB and Bluetooth HID devices on Linux, Mac and Windows.", + "homepage": "https://github.com/libusb/hidapi", + "supports": "windows & !(arm | arm64 | uwp)" +} |
