vcpkg/ports/libusb/portfile.cmake
Jack·Boos·Yu e8e660a36c
[vcpkg baseline][pangolin] Add features, fix dependency pybind11 (#20006)
* [vcpkg baseline][pangolin] Add features, fix dependency pybind11

* Fix dependency name realsense2

* Remove default-feature gles

* Re-generated patch, add MAYBE_UNUSED_VARIABLES, fix build with core

* version

* Fix desc, add more MAYBE_UNUSED_VARIABLES

* version

* more MAYBE_UNUSED_VARIABLES

* version

* Remove some CMAKE_DISABLE_FIND_PACKAGE_*

* version

* Remove more CMAKE_DISABLE_FIND_* since they are disabled

* Remove BUILD_FOR_GLES_2

* version

* Restore BUILD_FOR_GLES_2

* version

* Fix more dependencies

* [libuvc]Fix build type, fix usage

* version

* Re-make patch

* version

* Use libjpeg macros instead of target name to avoid use `find_dependency`

* version

* Fix usage on non-Windows

* version

* commit suggestions

* version

* Apply suggestion

* version

* Re-fix JPEG

* version

* typo

* format

* version

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
2021-09-10 13:41:46 -07:00

63 lines
2.9 KiB
CMake

vcpkg_fail_port_install(ON_TARGET "uwp")
if(VCPKG_TARGET_IS_LINUX)
message("${PORT} currently requires the following tools and libraries from the system package manager:\n autoreconf\n libudev\n\nThese can be installed on Ubuntu systems via apt-get install autoreconf libudev-dev")
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO libusb/libusb
REF c6a35c56016ea2ab2f19115d2ea1e85e0edae155 # v1.0.24
SHA512 985c020d9ae6f7135e3bfee68dddcf70921481db3d10e420f55d5ee9534f7fe7be6a2a31ee73a3b282b649fcc36da4fed848e0bd0410c20eaf1deb9a8e3086e8
HEAD_REF master
)
if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_PLATFORM_TOOLSET MATCHES "v142")
set(MSVS_VERSION 2019)
elseif(VCPKG_PLATFORM_TOOLSET MATCHES "v141")
set(MSVS_VERSION 2017)
else()
set(MSVS_VERSION 2015)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(LIBUSB_PROJECT_TYPE dll)
if (VCPKG_CRT_LINKAGE STREQUAL static)
file(READ "${SOURCE_PATH}/msvc/libusb_${LIBUSB_PROJECT_TYPE}_${MSVS_VERSION}.vcxproj" PROJ_FILE)
string(REPLACE "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>" "<RuntimeLibrary>MultiThreaded</RuntimeLibrary>" PROJ_FILE "${PROJ_FILE}")
string(REPLACE "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>" "<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>" PROJ_FILE "${PROJ_FILE}")
file(WRITE "${SOURCE_PATH}/msvc/libusb_${LIBUSB_PROJECT_TYPE}_${MSVS_VERSION}.vcxproj" "${PROJ_FILE}")
endif()
else()
set(LIBUSB_PROJECT_TYPE static)
if (VCPKG_CRT_LINKAGE STREQUAL dynamic)
file(READ "${SOURCE_PATH}/msvc/libusb_${LIBUSB_PROJECT_TYPE}_${MSVS_VERSION}.vcxproj" PROJ_FILE)
string(REPLACE "<RuntimeLibrary>MultiThreaded</RuntimeLibrary>" "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>" PROJ_FILE "${PROJ_FILE}")
string(REPLACE "<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>" "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>" PROJ_FILE "${PROJ_FILE}")
file(WRITE "${SOURCE_PATH}/msvc/libusb_${LIBUSB_PROJECT_TYPE}_${MSVS_VERSION}.vcxproj" "${PROJ_FILE}")
endif()
endif()
# The README.md file in the archive is a symlink to README
# which causes issues with the windows MSBUILD process
file(REMOVE ${SOURCE_PATH}/README.md)
vcpkg_install_msbuild(
SOURCE_PATH ${SOURCE_PATH}
PROJECT_SUBPATH msvc/libusb_${LIBUSB_PROJECT_TYPE}_${MSVS_VERSION}.vcxproj
LICENSE_SUBPATH COPYING
)
file(INSTALL ${SOURCE_PATH}/libusb/libusb.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/libusb-1.0)
else()
vcpkg_configure_make(
SOURCE_PATH ${SOURCE_PATH}
AUTOCONFIG
)
vcpkg_install_make()
endif()
configure_file(${CURRENT_PORT_DIR}/usage ${CURRENT_PACKAGES_DIR}/share/${PORT}/usage @ONLY)
configure_file(${CURRENT_PORT_DIR}/vcpkg-cmake-wrapper.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)