diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
| commit | 5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch) | |
| tree | 8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/src/hidapi/libusb/CMakeLists.txt | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/hidapi/libusb/CMakeLists.txt')
| -rw-r--r-- | contrib/SDL-3.2.8/src/hidapi/libusb/CMakeLists.txt | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/hidapi/libusb/CMakeLists.txt b/contrib/SDL-3.2.8/src/hidapi/libusb/CMakeLists.txt new file mode 100644 index 0000000..4c458c5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/hidapi/libusb/CMakeLists.txt | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR) | ||
| 2 | |||
| 3 | list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_libusb.h") | ||
| 4 | |||
| 5 | add_library(hidapi_libusb | ||
| 6 | ${HIDAPI_PUBLIC_HEADERS} | ||
| 7 | hid.c | ||
| 8 | ) | ||
| 9 | target_link_libraries(hidapi_libusb PUBLIC hidapi_include) | ||
| 10 | |||
| 11 | if(TARGET usb-1.0) | ||
| 12 | target_link_libraries(hidapi_libusb PRIVATE usb-1.0) | ||
| 13 | else() | ||
| 14 | include(FindPkgConfig) | ||
| 15 | pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0>=1.0.9) | ||
| 16 | target_link_libraries(hidapi_libusb PRIVATE PkgConfig::libusb) | ||
| 17 | endif() | ||
| 18 | |||
| 19 | find_package(Threads REQUIRED) | ||
| 20 | target_link_libraries(hidapi_libusb PRIVATE Threads::Threads) | ||
| 21 | |||
| 22 | if(HIDAPI_NO_ICONV) | ||
| 23 | target_compile_definitions(hidapi_libusb PRIVATE NO_ICONV) | ||
| 24 | else() | ||
| 25 | if(NOT ANDROID) | ||
| 26 | include(CheckCSourceCompiles) | ||
| 27 | |||
| 28 | if(NOT CMAKE_VERSION VERSION_LESS 3.11) | ||
| 29 | message(STATUS "Check for Iconv") | ||
| 30 | find_package(Iconv) | ||
| 31 | if(Iconv_FOUND) | ||
| 32 | if(NOT Iconv_IS_BUILT_IN) | ||
| 33 | target_link_libraries(hidapi_libusb PRIVATE Iconv::Iconv) | ||
| 34 | set(CMAKE_REQUIRED_LIBRARIES "Iconv::Iconv") | ||
| 35 | if(NOT BUILD_SHARED_LIBS) | ||
| 36 | set(HIDAPI_NEED_EXPORT_ICONV TRUE PARENT_SCOPE) | ||
| 37 | endif() | ||
| 38 | endif() | ||
| 39 | else() | ||
| 40 | message(STATUS "Iconv Explicitly check '-liconv'") | ||
| 41 | # Sometime the build environment is not setup | ||
| 42 | # in a way CMake can find Iconv on its own by default. | ||
| 43 | # But if we simply link against iconv (-liconv), the build may succeed | ||
| 44 | # due to other compiler/link flags. | ||
| 45 | set(CMAKE_REQUIRED_LIBRARIES "iconv") | ||
| 46 | check_c_source_compiles(" | ||
| 47 | #include <stddef.h> | ||
| 48 | #include <iconv.h> | ||
| 49 | int main() { | ||
| 50 | char *a, *b; | ||
| 51 | size_t i, j; | ||
| 52 | iconv_t ic; | ||
| 53 | ic = iconv_open(\"to\", \"from\"); | ||
| 54 | iconv(ic, &a, &i, &b, &j); | ||
| 55 | iconv_close(ic); | ||
| 56 | } | ||
| 57 | " | ||
| 58 | Iconv_EXPLICITLY_AT_ENV) | ||
| 59 | if(Iconv_EXPLICITLY_AT_ENV) | ||
| 60 | message(STATUS "Iconv Explicitly check '-liconv' - Available") | ||
| 61 | target_link_libraries(hidapi_libusb PRIVATE iconv) | ||
| 62 | else() | ||
| 63 | message(FATAL_ERROR "Iconv is not found, make sure to provide it in the build environment") | ||
| 64 | endif() | ||
| 65 | endif() | ||
| 66 | else() | ||
| 67 | # otherwise there is 2 options: | ||
| 68 | # 1) iconv is provided by Standard C library and the build will be just fine | ||
| 69 | # 2) The _user_ has to provide additional compilation options for this project/target | ||
| 70 | endif() | ||
| 71 | |||
| 72 | # check for error: "conflicting types for 'iconv'" | ||
| 73 | check_c_source_compiles("#include<iconv.h> | ||
| 74 | extern size_t iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); | ||
| 75 | int main() {}" | ||
| 76 | HIDAPI_ICONV_CONST) | ||
| 77 | if(HIDAPI_ICONV_CONST) | ||
| 78 | target_compile_definitions(hidapi_libusb PRIVATE "ICONV_CONST=const") | ||
| 79 | endif() | ||
| 80 | else() | ||
| 81 | # On Android Iconv is disabled on the code level anyway, so no issue; | ||
| 82 | endif() | ||
| 83 | endif() | ||
| 84 | |||
| 85 | set_target_properties(hidapi_libusb | ||
| 86 | PROPERTIES | ||
| 87 | EXPORT_NAME "libusb" | ||
| 88 | OUTPUT_NAME "hidapi-libusb" | ||
| 89 | VERSION ${PROJECT_VERSION} | ||
| 90 | SOVERSION ${PROJECT_VERSION_MAJOR} | ||
| 91 | PUBLIC_HEADER "${HIDAPI_PUBLIC_HEADERS}" | ||
| 92 | ) | ||
| 93 | |||
| 94 | # compatibility with find_package() | ||
| 95 | add_library(hidapi::libusb ALIAS hidapi_libusb) | ||
| 96 | # compatibility with raw library link | ||
| 97 | add_library(hidapi-libusb ALIAS hidapi_libusb) | ||
| 98 | |||
| 99 | if(HIDAPI_INSTALL_TARGETS) | ||
| 100 | install(TARGETS hidapi_libusb EXPORT hidapi | ||
| 101 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
| 102 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
| 103 | PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hidapi" | ||
| 104 | ) | ||
| 105 | endif() | ||
| 106 | |||
| 107 | hidapi_configure_pc("${PROJECT_ROOT}/pc/hidapi-libusb.pc.in") | ||
