mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 18:31:15 +08:00
[hidapi] Support static build (#15437)
* [hidapi] Support static build * Update portfile.cmake
This commit is contained in:
parent
c1e9424206
commit
1aba77ae3b
@ -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
|
@ -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()
|
||||
|
8
ports/hidapi/vcpkg.json
Normal file
8
ports/hidapi/vcpkg.json
Normal file
@ -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)"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user