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/CMakeLists.txt | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/hidapi/CMakeLists.txt')
| -rw-r--r-- | contrib/SDL-3.2.8/src/hidapi/CMakeLists.txt | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/hidapi/CMakeLists.txt b/contrib/SDL-3.2.8/src/hidapi/CMakeLists.txt new file mode 100644 index 0000000..d708681 --- /dev/null +++ b/contrib/SDL-3.2.8/src/hidapi/CMakeLists.txt | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | cmake_minimum_required(VERSION 3.1.3...3.25 FATAL_ERROR) | ||
| 2 | |||
| 3 | if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) | ||
| 4 | add_subdirectory(src) | ||
| 5 | # compatibility with find_package() vs add_subdirectory | ||
| 6 | set(hidapi_VERSION "${hidapi_VERSION}" PARENT_SCOPE) | ||
| 7 | return() | ||
| 8 | endif() | ||
| 9 | # All of the below in this file is meant for a standalone build. | ||
| 10 | # When building as a subdirectory of a larger project, most of the options may not make sense for it, | ||
| 11 | # so it is up to developer to configure those, e.g.: | ||
| 12 | # | ||
| 13 | # # a subfolder of a master project, e.g.: 3rdparty/hidapi/CMakeLists.txt | ||
| 14 | # | ||
| 15 | # set(HIDAPI_WITH_HIDRAW OFF) | ||
| 16 | # set(CMAKE_FRAMEWORK ON) | ||
| 17 | # # and keep everything else to their defaults | ||
| 18 | # add_subdirectory(hidapi) | ||
| 19 | # | ||
| 20 | |||
| 21 | set(DEFAULT_CMAKE_BUILD_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo") | ||
| 22 | if(NOT DEFINED CMAKE_BUILD_TYPE OR NOT CMAKE_BUILD_TYPE) | ||
| 23 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "${DEFAULT_CMAKE_BUILD_TYPES}" FORCE) | ||
| 24 | endif() | ||
| 25 | # This part is for convenience, when used one of the standard build types with cmake-gui | ||
| 26 | list(FIND DEFAULT_CMAKE_BUILD_TYPES "${CMAKE_BUILD_TYPE}" _build_type_index) | ||
| 27 | if(${_build_type_index} GREATER -1) | ||
| 28 | # set it optionally, so a custom CMAKE_BUILD_TYPE can be used as well, if needed | ||
| 29 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${DEFAULT_CMAKE_BUILD_TYPES}) | ||
| 30 | endif() | ||
| 31 | unset(_build_type_index) | ||
| 32 | # | ||
| 33 | |||
| 34 | project(hidapi LANGUAGES C) | ||
| 35 | |||
| 36 | if(APPLE) | ||
| 37 | if(NOT CMAKE_VERSION VERSION_LESS "3.15") | ||
| 38 | option(CMAKE_FRAMEWORK "Build macOS/iOS Framework version of the library" OFF) | ||
| 39 | endif() | ||
| 40 | elseif(NOT WIN32) | ||
| 41 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") | ||
| 42 | option(HIDAPI_WITH_HIDRAW "Build HIDRAW-based implementation of HIDAPI" ON) | ||
| 43 | option(HIDAPI_WITH_LIBUSB "Build LIBUSB-based implementation of HIDAPI" ON) | ||
| 44 | endif() | ||
| 45 | if(CMAKE_SYSTEM_NAME MATCHES "NetBSD") | ||
| 46 | option(HIDAPI_WITH_NETBSD "Build NetBSD/UHID implementation of HIDAPI" ON) | ||
| 47 | endif() | ||
| 48 | endif() | ||
| 49 | |||
| 50 | option(BUILD_SHARED_LIBS "Build shared version of the libraries, otherwise build statically" ON) | ||
| 51 | |||
| 52 | set(HIDAPI_INSTALL_TARGETS ON) | ||
| 53 | set(HIDAPI_PRINT_VERSION ON) | ||
| 54 | |||
| 55 | set(IS_DEBUG_BUILD OFF) | ||
| 56 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| 57 | set(IS_DEBUG_BUILD ON) | ||
| 58 | endif() | ||
| 59 | |||
| 60 | option(HIDAPI_ENABLE_ASAN "Build HIDAPI with ASAN address sanitizer instrumentation" OFF) | ||
| 61 | |||
| 62 | if(HIDAPI_ENABLE_ASAN) | ||
| 63 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") | ||
| 64 | if(MSVC) | ||
| 65 | # the default is to have "/INCREMENTAL" which causes a warning when "-fsanitize=address" is present | ||
| 66 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO") | ||
| 67 | set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO") | ||
| 68 | set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO") | ||
| 69 | set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO") | ||
| 70 | endif() | ||
| 71 | endif() | ||
| 72 | |||
| 73 | if(WIN32) | ||
| 74 | # so far only Windows has tests | ||
| 75 | option(HIDAPI_WITH_TESTS "Build HIDAPI (unit-)tests" ${IS_DEBUG_BUILD}) | ||
| 76 | else() | ||
| 77 | set(HIDAPI_WITH_TESTS OFF) | ||
| 78 | endif() | ||
| 79 | |||
| 80 | if(HIDAPI_WITH_TESTS) | ||
| 81 | enable_testing() | ||
| 82 | endif() | ||
| 83 | |||
| 84 | if(WIN32) | ||
| 85 | option(HIDAPI_BUILD_PP_DATA_DUMP "Build small Windows console application pp_data_dump.exe" ${IS_DEBUG_BUILD}) | ||
| 86 | endif() | ||
| 87 | |||
| 88 | add_subdirectory(src) | ||
| 89 | |||
| 90 | option(HIDAPI_BUILD_HIDTEST "Build small console test application hidtest" ${IS_DEBUG_BUILD}) | ||
| 91 | if(HIDAPI_BUILD_HIDTEST) | ||
| 92 | add_subdirectory(hidtest) | ||
| 93 | endif() | ||
| 94 | |||
| 95 | if(HIDAPI_ENABLE_ASAN) | ||
| 96 | if(NOT MSVC) | ||
| 97 | # MSVC doesn't recognize those options, other compilers - requiring it | ||
| 98 | foreach(HIDAPI_TARGET hidapi_winapi hidapi_darwin hidapi_hidraw hidapi_libusb hidtest_hidraw hidtest_libusb hidtest) | ||
| 99 | if(TARGET ${HIDAPI_TARGET}) | ||
| 100 | if(BUILD_SHARED_LIBS) | ||
| 101 | target_link_options(${HIDAPI_TARGET} PRIVATE -fsanitize=address) | ||
| 102 | else() | ||
| 103 | target_link_options(${HIDAPI_TARGET} PUBLIC -fsanitize=address) | ||
| 104 | endif() | ||
| 105 | endif() | ||
| 106 | endforeach() | ||
| 107 | endif() | ||
| 108 | endif() | ||
