-
Notifications
You must be signed in to change notification settings - Fork 23
/
CMakeLists.txt
41 lines (35 loc) · 1.36 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
cmake_minimum_required(VERSION 3.8)
project(hidpp)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(BUILD_TOOLS "Build HID++ command line tools" ON)
option(INSTALL_UDEV_RULES "Install udev rules for user access to HID++ devices (requires building tools)" OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(DEFAULT_HID_BACKEND "linux")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(DEFAULT_HID_BACKEND "windows")
else()
message(WARNING "System is not supported")
endif()
set(HID_BACKEND "${DEFAULT_HID_BACKEND}" CACHE STRING "Backend used for accessing HID devices")
set_property(CACHE HID_BACKEND PROPERTY STRINGS linux windows)
find_package(Threads REQUIRED)
if("${HID_BACKEND}" STREQUAL "linux")
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBUDEV libudev REQUIRED)
elseif("${HID_BACKEND}" STREQUAL "windows")
else()
message(FATAL_ERROR "HID_BACKEND is invalid.")
endif()
include(GNUInstallDirs)
add_subdirectory(src/libhidpp)
add_subdirectory(doc/libhidpp)
if(BUILD_TOOLS)
add_subdirectory(src/tools)
if(INSTALL_UDEV_RULES)
set(PREFIX ${CMAKE_INSTALL_PREFIX})
configure_file(udev/rules.d/69-hidpp.rules.in udev/rules.d/69-hidpp.rules @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/udev/rules.d/69-hidpp.rules DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/udev/rules.d)
endif()
endif()