Skip to content

Commit 5a0a29b

Browse files
CopilotYouw
andauthored
cmake: share backend policy setup without warning regressions
Agent-Logs-Url: https://github.com/libusb/hidapi/sessions/c4b6aaeb-8b94-4451-a245-d4a6fe7f7421 Co-authored-by: Youw <5939659+Youw@users.noreply.github.com>
1 parent 6836ea0 commit 5a0a29b

6 files changed

Lines changed: 11 additions & 30 deletions

File tree

libusb/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR)
22

3-
foreach(HIDAPI_CMAKE_POLICY CMP0156 CMP0179 CMP0181 CMP0200)
4-
if(POLICY ${HIDAPI_CMAKE_POLICY})
5-
cmake_policy(SET ${HIDAPI_CMAKE_POLICY} NEW)
6-
endif()
7-
endforeach()
8-
unset(HIDAPI_CMAKE_POLICY)
3+
include("${PROJECT_ROOT}/src/cmake/hidapi-policies.cmake" NO_POLICY_SCOPE)
94

105
list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_libusb.h")
116

linux/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR)
22

3-
foreach(HIDAPI_CMAKE_POLICY CMP0156 CMP0179 CMP0181 CMP0200)
4-
if(POLICY ${HIDAPI_CMAKE_POLICY})
5-
cmake_policy(SET ${HIDAPI_CMAKE_POLICY} NEW)
6-
endif()
7-
endforeach()
8-
unset(HIDAPI_CMAKE_POLICY)
3+
include("${PROJECT_ROOT}/src/cmake/hidapi-policies.cmake" NO_POLICY_SCOPE)
94

105
add_library(hidapi_hidraw
116
${HIDAPI_PUBLIC_HEADERS}

mac/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
cmake_minimum_required(VERSION 3.4.3...3.25 FATAL_ERROR)
22

3-
foreach(HIDAPI_CMAKE_POLICY CMP0156 CMP0179 CMP0181 CMP0200)
4-
if(POLICY ${HIDAPI_CMAKE_POLICY})
5-
cmake_policy(SET ${HIDAPI_CMAKE_POLICY} NEW)
6-
endif()
7-
endforeach()
8-
unset(HIDAPI_CMAKE_POLICY)
3+
include("${PROJECT_ROOT}/src/cmake/hidapi-policies.cmake" NO_POLICY_SCOPE)
94

105
list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_darwin.h")
116

netbsd/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR)
22

3-
foreach(HIDAPI_CMAKE_POLICY CMP0156 CMP0179 CMP0181 CMP0200)
4-
if(POLICY ${HIDAPI_CMAKE_POLICY})
5-
cmake_policy(SET ${HIDAPI_CMAKE_POLICY} NEW)
6-
endif()
7-
endforeach()
8-
unset(HIDAPI_CMAKE_POLICY)
3+
include("${PROJECT_ROOT}/src/cmake/hidapi-policies.cmake" NO_POLICY_SCOPE)
94

105
add_library(hidapi_netbsd
116
${HIDAPI_PUBLIC_HEADERS}

src/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ project(hidapi VERSION "${VERSION}" LANGUAGES C)
2626

2727
# Defaults and required options
2828

29-
foreach(HIDAPI_CMAKE_POLICY CMP0156 CMP0179 CMP0181 CMP0200)
30-
if(POLICY ${HIDAPI_CMAKE_POLICY})
31-
cmake_policy(SET ${HIDAPI_CMAKE_POLICY} NEW)
32-
endif()
33-
endforeach()
34-
unset(HIDAPI_CMAKE_POLICY)
29+
include("${PROJECT_ROOT}/src/cmake/hidapi-policies.cmake" NO_POLICY_SCOPE)
3530

3631
if(NOT DEFINED HIDAPI_WITH_TESTS)
3732
set(HIDAPI_WITH_TESTS OFF)

src/cmake/hidapi-policies.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
foreach(HIDAPI_CMAKE_POLICY CMP0156 CMP0179 CMP0181 CMP0200)
2+
if(POLICY ${HIDAPI_CMAKE_POLICY})
3+
cmake_policy(SET ${HIDAPI_CMAKE_POLICY} NEW)
4+
endif()
5+
endforeach()
6+
unset(HIDAPI_CMAKE_POLICY)

0 commit comments

Comments
 (0)