Skip to content

Commit 762470b

Browse files
authored
cmake: declare version and policy requirements once at the top level (#808)
Each backend subdirectory (libusb, linux, mac, netbsd) called cmake_minimum_required() with its own version range. That call resets the CMake policy stack to the range's upper bound, discarding policies introduced later. When hidapi is built as a CMake subproject (e.g. the Meson cmake.subproject path), a modern CMake then emits dev warnings for CMP0156/CMP0181/CMP0200 right after each backend's call. The backends have no project() of their own and are never configured standalone, so their cmake_minimum_required() calls served no purpose beyond resetting policies. Remove them; the backends now inherit the single policy baseline from the top-level CMakeLists.txt, matching what windows/CMakeLists.txt already did. Raise the top-level range to 3.6.3...4.3: 3.6.3 is the real floor (it was already required by the linux/libusb/netbsd backends), and the 4.3 upper bound sets every current policy to NEW. hidtest keeps its own cmake_minimum_required() because it is also built as a standalone project; its upper bound is raised to 4.3 so it behaves identically whether built standalone or as a subdirectory. Assisted-by: Claude:claude-opus-4.7
1 parent f5a0f74 commit 762470b

6 files changed

Lines changed: 2 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.1.3...3.25 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.6.3...4.3 FATAL_ERROR)
22

33
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
44
add_subdirectory(src)

hidtest/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.1.3...3.25 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.1.3...4.3 FATAL_ERROR)
22
project(hidtest C)
33

44
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

libusb/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR)
2-
31
list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_libusb.h")
42

53
add_library(hidapi_libusb

linux/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR)
2-
31
add_library(hidapi_hidraw
42
${HIDAPI_PUBLIC_HEADERS}
53
hid.c

mac/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
cmake_minimum_required(VERSION 3.4.3...3.25 FATAL_ERROR)
2-
31
list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_darwin.h")
42

53
add_library(hidapi_darwin

netbsd/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR)
2-
31
add_library(hidapi_netbsd
42
${HIDAPI_PUBLIC_HEADERS}
53
hid.c

0 commit comments

Comments
 (0)