diff options
Diffstat (limited to 'SDL-3.2.8/src/hidapi/src/CMakeLists.txt')
| -rw-r--r-- | SDL-3.2.8/src/hidapi/src/CMakeLists.txt | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/SDL-3.2.8/src/hidapi/src/CMakeLists.txt b/SDL-3.2.8/src/hidapi/src/CMakeLists.txt new file mode 100644 index 0000000..e663c3f --- /dev/null +++ b/SDL-3.2.8/src/hidapi/src/CMakeLists.txt | |||
| @@ -0,0 +1,206 @@ | |||
| 1 | get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) | ||
| 2 | |||
| 3 | # Read version from file | ||
| 4 | file(READ "${PROJECT_ROOT}/VERSION" RAW_VERSION_STR) | ||
| 5 | string(REGEX MATCH "^([0-9]+\\.[0-9]+\\.[0-9]+)(.*)" VERSION_STR "${RAW_VERSION_STR}") | ||
| 6 | |||
| 7 | if(NOT VERSION_STR) | ||
| 8 | message(FATAL_ERROR "Broken VERSION file, couldn't parse '${PROJECT_ROOT}/VERSION' with content: '${RAW_VERSION_STR}'") | ||
| 9 | endif() | ||
| 10 | |||
| 11 | set(VERSION "${CMAKE_MATCH_1}") | ||
| 12 | string(STRIP "${CMAKE_MATCH_2}" VERSION_SUFFIX) | ||
| 13 | # compatibility with find_package() vs add_subdirectory | ||
| 14 | set(hidapi_VERSION "${VERSION}" PARENT_SCOPE) | ||
| 15 | # | ||
| 16 | |||
| 17 | if(DEFINED HIDAPI_PRINT_VERSION AND HIDAPI_PRINT_VERSION) | ||
| 18 | set(HIDAPI_PRINT_VERSION "hidapi: v${VERSION}") | ||
| 19 | if(VERSION_SUFFIX) | ||
| 20 | set(HIDAPI_PRINT_VERSION "${HIDAPI_PRINT_VERSION} (${VERSION_SUFFIX})") | ||
| 21 | endif() | ||
| 22 | message(STATUS "${HIDAPI_PRINT_VERSION}") | ||
| 23 | endif() | ||
| 24 | |||
| 25 | project(hidapi VERSION "${VERSION}" LANGUAGES C) | ||
| 26 | |||
| 27 | # Defaults and required options | ||
| 28 | |||
| 29 | if(NOT DEFINED HIDAPI_WITH_TESTS) | ||
| 30 | set(HIDAPI_WITH_TESTS OFF) | ||
| 31 | endif() | ||
| 32 | if(NOT DEFINED BUILD_SHARED_LIBS) | ||
| 33 | set(BUILD_SHARED_LIBS ON) | ||
| 34 | endif() | ||
| 35 | if(NOT DEFINED HIDAPI_INSTALL_TARGETS) | ||
| 36 | set(HIDAPI_INSTALL_TARGETS OFF) | ||
| 37 | endif() | ||
| 38 | if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) | ||
| 39 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
| 40 | endif() | ||
| 41 | |||
| 42 | get_directory_property(IS_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL) | ||
| 43 | if(IS_EXCLUDE_FROM_ALL) | ||
| 44 | if(HIDAPI_INSTALL_TARGETS) | ||
| 45 | message(WARNING "Installing EXCLUDE_FROM_ALL targets in an undefined behavior in CMake.\nDon't add 'hidapi' sundirectory with 'EXCLUDE_FROM_ALL' property, or don't set 'HIDAPI_INSTALL_TARGETS' to TRUE.") | ||
| 46 | endif() | ||
| 47 | endif() | ||
| 48 | |||
| 49 | # Helper(s) | ||
| 50 | |||
| 51 | function(hidapi_configure_pc PC_IN_FILE) | ||
| 52 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pc") | ||
| 53 | |||
| 54 | set(VERSION "${VERSION}${VERSION_SUFFIX}") | ||
| 55 | set(prefix "${CMAKE_INSTALL_PREFIX}") | ||
| 56 | set(exec_prefix "\${prefix}") | ||
| 57 | if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") | ||
| 58 | set(libdir "${CMAKE_INSTALL_LIBDIR}") | ||
| 59 | else() | ||
| 60 | set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") | ||
| 61 | endif() | ||
| 62 | if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") | ||
| 63 | set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") | ||
| 64 | else() | ||
| 65 | set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") | ||
| 66 | endif() | ||
| 67 | |||
| 68 | get_filename_component(PC_IN_FILENAME "${PC_IN_FILE}" NAME_WE) | ||
| 69 | set(PC_FILE "${CMAKE_CURRENT_BINARY_DIR}/pc/${PC_IN_FILENAME}.pc") | ||
| 70 | configure_file("${PC_IN_FILE}" "${PC_FILE}" @ONLY) | ||
| 71 | if(HIDAPI_INSTALL_TARGETS) | ||
| 72 | install(FILES "${PC_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") | ||
| 73 | endif() | ||
| 74 | endfunction() | ||
| 75 | |||
| 76 | # The library | ||
| 77 | |||
| 78 | if(HIDAPI_INSTALL_TARGETS) | ||
| 79 | include(GNUInstallDirs) | ||
| 80 | endif() | ||
| 81 | |||
| 82 | add_library(hidapi_include INTERFACE) | ||
| 83 | target_include_directories(hidapi_include INTERFACE | ||
| 84 | "$<BUILD_INTERFACE:${PROJECT_ROOT}/hidapi>" | ||
| 85 | ) | ||
| 86 | if(APPLE AND CMAKE_FRAMEWORK) | ||
| 87 | # FIXME: https://github.com/libusb/hidapi/issues/492: it is untrivial to set the include path for Framework correctly | ||
| 88 | else() | ||
| 89 | target_include_directories(hidapi_include INTERFACE | ||
| 90 | "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/hidapi>" | ||
| 91 | ) | ||
| 92 | endif() | ||
| 93 | set_target_properties(hidapi_include PROPERTIES EXPORT_NAME "include") | ||
| 94 | set(HIDAPI_PUBLIC_HEADERS "${PROJECT_ROOT}/hidapi/hidapi.h") | ||
| 95 | |||
| 96 | add_library(hidapi::include ALIAS hidapi_include) | ||
| 97 | |||
| 98 | if(HIDAPI_INSTALL_TARGETS) | ||
| 99 | install(TARGETS hidapi_include EXPORT hidapi) | ||
| 100 | endif() | ||
| 101 | |||
| 102 | set(EXPORT_ALIAS) | ||
| 103 | set(EXPORT_COMPONENTS) | ||
| 104 | |||
| 105 | set(HIDAPI_NEED_EXPORT_THREADS FALSE) | ||
| 106 | set(HIDAPI_NEED_EXPORT_LIBUSB FALSE) | ||
| 107 | set(HIDAPI_NEED_EXPORT_LIBUDEV FALSE) | ||
| 108 | set(HIDAPI_NEED_EXPORT_ICONV FALSE) | ||
| 109 | |||
| 110 | if(WIN32) | ||
| 111 | target_include_directories(hidapi_include INTERFACE | ||
| 112 | "$<BUILD_INTERFACE:${PROJECT_ROOT}/windows>" | ||
| 113 | ) | ||
| 114 | add_subdirectory("${PROJECT_ROOT}/windows" windows) | ||
| 115 | set(EXPORT_ALIAS winapi) | ||
| 116 | list(APPEND EXPORT_COMPONENTS winapi) | ||
| 117 | elseif(APPLE) | ||
| 118 | target_include_directories(hidapi_include INTERFACE | ||
| 119 | "$<BUILD_INTERFACE:${PROJECT_ROOT}/mac>" | ||
| 120 | ) | ||
| 121 | add_subdirectory("${PROJECT_ROOT}/mac" mac) | ||
| 122 | set(EXPORT_ALIAS darwin) | ||
| 123 | list(APPEND EXPORT_COMPONENTS darwin) | ||
| 124 | if(NOT BUILD_SHARED_LIBS) | ||
| 125 | set(HIDAPI_NEED_EXPORT_THREADS TRUE) | ||
| 126 | endif() | ||
| 127 | else() | ||
| 128 | if(NOT DEFINED HIDAPI_WITH_LIBUSB) | ||
| 129 | set(HIDAPI_WITH_LIBUSB ON) | ||
| 130 | endif() | ||
| 131 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") | ||
| 132 | if(NOT DEFINED HIDAPI_WITH_HIDRAW) | ||
| 133 | set(HIDAPI_WITH_HIDRAW ON) | ||
| 134 | endif() | ||
| 135 | if(HIDAPI_WITH_HIDRAW) | ||
| 136 | add_subdirectory("${PROJECT_ROOT}/linux" linux) | ||
| 137 | list(APPEND EXPORT_COMPONENTS hidraw) | ||
| 138 | set(EXPORT_ALIAS hidraw) | ||
| 139 | if(NOT BUILD_SHARED_LIBS) | ||
| 140 | set(HIDAPI_NEED_EXPORT_THREADS TRUE) | ||
| 141 | set(HIDAPI_NEED_EXPORT_LIBUDEV TRUE) | ||
| 142 | endif() | ||
| 143 | endif() | ||
| 144 | elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD") | ||
| 145 | if(NOT DEFINED HIDAPI_WITH_NETBSD) | ||
| 146 | set(HIDAPI_WITH_NETBSD ON) | ||
| 147 | endif() | ||
| 148 | if(HIDAPI_WITH_NETBSD) | ||
| 149 | add_subdirectory("${PROJECT_ROOT}/netbsd" netbsd) | ||
| 150 | list(APPEND EXPORT_COMPONENTS netbsd) | ||
| 151 | set(EXPORT_ALIAS netbsd) | ||
| 152 | if(NOT BUILD_SHARED_LIBS) | ||
| 153 | set(HIDAPI_NEED_EXPORT_THREADS TRUE) | ||
| 154 | endif() | ||
| 155 | endif() | ||
| 156 | else() | ||
| 157 | set(HIDAPI_WITH_LIBUSB ON) | ||
| 158 | endif() | ||
| 159 | if(HIDAPI_WITH_LIBUSB) | ||
| 160 | target_include_directories(hidapi_include INTERFACE | ||
| 161 | "$<BUILD_INTERFACE:${PROJECT_ROOT}/libusb>" | ||
| 162 | ) | ||
| 163 | if(NOT DEFINED HIDAPI_NO_ICONV) | ||
| 164 | set(HIDAPI_NO_ICONV OFF) | ||
| 165 | endif() | ||
| 166 | add_subdirectory("${PROJECT_ROOT}/libusb" libusb) | ||
| 167 | list(APPEND EXPORT_COMPONENTS libusb) | ||
| 168 | if(NOT EXPORT_ALIAS) | ||
| 169 | set(EXPORT_ALIAS libusb) | ||
| 170 | endif() | ||
| 171 | if(NOT BUILD_SHARED_LIBS) | ||
| 172 | set(HIDAPI_NEED_EXPORT_THREADS TRUE) | ||
| 173 | if(NOT TARGET usb-1.0) | ||
| 174 | set(HIDAPI_NEED_EXPORT_LIBUSB TRUE) | ||
| 175 | endif() | ||
| 176 | endif() | ||
| 177 | elseif(NOT TARGET hidapi_hidraw) | ||
| 178 | message(FATAL_ERROR "Select at least one option to build: HIDAPI_WITH_LIBUSB or HIDAPI_WITH_HIDRAW") | ||
| 179 | endif() | ||
| 180 | endif() | ||
| 181 | |||
| 182 | add_library(hidapi::hidapi ALIAS hidapi_${EXPORT_ALIAS}) | ||
| 183 | |||
| 184 | if(HIDAPI_INSTALL_TARGETS) | ||
| 185 | include(CMakePackageConfigHelpers) | ||
| 186 | set(EXPORT_DENERATED_LOCATION "${CMAKE_BINARY_DIR}/export_generated") | ||
| 187 | set(EXPORT_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hidapi") | ||
| 188 | write_basic_package_version_file("${EXPORT_DENERATED_LOCATION}/hidapi-config-version.cmake" | ||
| 189 | COMPATIBILITY SameMajorVersion | ||
| 190 | ) | ||
| 191 | configure_package_config_file("cmake/hidapi-config.cmake.in" "${EXPORT_DENERATED_LOCATION}/hidapi-config.cmake" | ||
| 192 | INSTALL_DESTINATION "${EXPORT_DESTINATION}" | ||
| 193 | NO_SET_AND_CHECK_MACRO | ||
| 194 | ) | ||
| 195 | |||
| 196 | install(EXPORT hidapi | ||
| 197 | DESTINATION "${EXPORT_DESTINATION}" | ||
| 198 | NAMESPACE hidapi:: | ||
| 199 | FILE "libhidapi.cmake" | ||
| 200 | ) | ||
| 201 | install(FILES | ||
| 202 | "${EXPORT_DENERATED_LOCATION}/hidapi-config-version.cmake" | ||
| 203 | "${EXPORT_DENERATED_LOCATION}/hidapi-config.cmake" | ||
| 204 | DESTINATION "${EXPORT_DESTINATION}" | ||
| 205 | ) | ||
| 206 | endif() | ||
