From 02b6441764ceae16eab0a813b68ab97c702b748f Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Tue, 19 May 2026 23:54:08 +0300 Subject: [PATCH] cmake: declare version and policy requirements once at the top level 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 --- CMakeLists.txt | 2 +- hidtest/CMakeLists.txt | 2 +- libusb/CMakeLists.txt | 2 -- linux/CMakeLists.txt | 2 -- mac/CMakeLists.txt | 2 -- netbsd/CMakeLists.txt | 2 -- 6 files changed, 2 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7086813c..beca172b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1.3...3.25 FATAL_ERROR) +cmake_minimum_required(VERSION 3.6.3...4.3 FATAL_ERROR) if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) add_subdirectory(src) diff --git a/hidtest/CMakeLists.txt b/hidtest/CMakeLists.txt index 19c50e1fb..b7ceae7ea 100644 --- a/hidtest/CMakeLists.txt +++ b/hidtest/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1.3...3.25 FATAL_ERROR) +cmake_minimum_required(VERSION 3.1.3...4.3 FATAL_ERROR) project(hidtest C) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) diff --git a/libusb/CMakeLists.txt b/libusb/CMakeLists.txt index 4c458c569..2228bd6c0 100644 --- a/libusb/CMakeLists.txt +++ b/libusb/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR) - list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_libusb.h") add_library(hidapi_libusb diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 9c627087f..dda5c8176 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR) - add_library(hidapi_hidraw ${HIDAPI_PUBLIC_HEADERS} hid.c diff --git a/mac/CMakeLists.txt b/mac/CMakeLists.txt index 1ff862bd7..8acd649c7 100644 --- a/mac/CMakeLists.txt +++ b/mac/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.4.3...3.25 FATAL_ERROR) - list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_darwin.h") add_library(hidapi_darwin diff --git a/netbsd/CMakeLists.txt b/netbsd/CMakeLists.txt index f76006d53..9be903c67 100644 --- a/netbsd/CMakeLists.txt +++ b/netbsd/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR) - add_library(hidapi_netbsd ${HIDAPI_PUBLIC_HEADERS} hid.c