Atlas - CMakeLists.txt
Home / ext / SDL / src / hidapi Lines: 1 | Size: 4048 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1cmake_minimum_required(VERSION 3.1.3...3.25 FATAL_ERROR) 2 3if(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() 8endif() 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 21set(DEFAULT_CMAKE_BUILD_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo") 22if(NOT DEFINED CMAKE_BUILD_TYPE OR NOT CMAKE_BUILD_TYPE) 23 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "${DEFAULT_CMAKE_BUILD_TYPES}" FORCE) 24endif() 25# This part is for convenience, when used one of the standard build types with cmake-gui 26list(FIND DEFAULT_CMAKE_BUILD_TYPES "${CMAKE_BUILD_TYPE}" _build_type_index) 27if(${_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}) 30endif() 31unset(_build_type_index) 32# 33 34project(hidapi LANGUAGES C) 35 36if(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() 40elseif(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() 48endif() 49 50option(BUILD_SHARED_LIBS "Build shared version of the libraries, otherwise build statically" ON) 51 52set(HIDAPI_INSTALL_TARGETS ON) 53set(HIDAPI_PRINT_VERSION ON) 54 55set(IS_DEBUG_BUILD OFF) 56if(CMAKE_BUILD_TYPE STREQUAL "Debug") 57 set(IS_DEBUG_BUILD ON) 58endif() 59 60option(HIDAPI_ENABLE_ASAN "Build HIDAPI with ASAN address sanitizer instrumentation" OFF) 61 62if(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() 71endif() 72 73if(WIN32) 74 # so far only Windows has tests 75 option(HIDAPI_WITH_TESTS "Build HIDAPI (unit-)tests" ${IS_DEBUG_BUILD}) 76else() 77 set(HIDAPI_WITH_TESTS OFF) 78endif() 79 80if(HIDAPI_WITH_TESTS) 81 enable_testing() 82endif() 83 84if(WIN32) 85 option(HIDAPI_BUILD_PP_DATA_DUMP "Build small Windows console application pp_data_dump.exe" ${IS_DEBUG_BUILD}) 86endif() 87 88add_subdirectory(src) 89 90option(HIDAPI_BUILD_HIDTEST "Build small console test application hidtest" ${IS_DEBUG_BUILD}) 91if(HIDAPI_BUILD_HIDTEST) 92 add_subdirectory(hidtest) 93endif() 94 95if(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() 108endif() 109[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.