mirror of
https://github.com/RPCS3/hidapi.git
synced 2026-07-20 05:53:38 -04:00
add .pc generation for CMake build
This commit is contained in:
+1
-1
@@ -11,8 +11,8 @@ if(APPLE)
|
||||
elseif(NOT WIN32)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
option(HIDAPI_WITH_HIDRAW "Build HIDRAW-based implementation of HIDAPI" ON)
|
||||
option(HIDAPI_WITH_LIBUSB "Build LIBUSB-based implementation of HIDAPI" ON)
|
||||
endif()
|
||||
option(HIDAPI_WITH_LIBUSB "Build LIBUSB-based implementation of HIDAPI" ON)
|
||||
endif()
|
||||
|
||||
option(BUILD_SHARED_LIBS "When set: build shared version of the libraries, otherwise - static" ON)
|
||||
|
||||
@@ -34,4 +34,10 @@ if(HIDAPI_INSTALL_TARGETS)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HIDAPI_LIBNAME_VERBOSE)
|
||||
hidapi_configure_pc("${PROJECT_ROOT}/pc/hidapi-libusb.pc.in")
|
||||
else()
|
||||
hidapi_configure_pc("${PROJECT_ROOT}/pc/hidapi.pc.in")
|
||||
endif()
|
||||
|
||||
add_library(hidapi ALIAS hidapi_libusb)
|
||||
|
||||
@@ -29,6 +29,8 @@ if(HIDAPI_INSTALL_TARGETS)
|
||||
)
|
||||
endif()
|
||||
|
||||
hidapi_configure_pc("${PROJECT_ROOT}/pc/hidapi-hidraw.pc.in")
|
||||
|
||||
if(NOT HIDAPI_WITH_LIBUSB)
|
||||
add_library(hidapi ALIAS hidapi_hidraw)
|
||||
endif()
|
||||
|
||||
@@ -38,4 +38,6 @@ if(HIDAPI_INSTALL_TARGETS)
|
||||
)
|
||||
endif()
|
||||
|
||||
hidapi_configure_pc("${PROJECT_ROOT}/pc/hidapi.pc.in")
|
||||
|
||||
add_library(hidapi ALIAS hidapi_darwin)
|
||||
|
||||
@@ -5,6 +5,7 @@ includedir=@includedir@
|
||||
|
||||
Name: hidapi-hidraw
|
||||
Description: C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the hidraw implementation.
|
||||
URL: https://github.com/libusb/hidapi
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lhidapi-hidraw
|
||||
Cflags: -I${includedir}/hidapi
|
||||
|
||||
@@ -5,6 +5,7 @@ includedir=@includedir@
|
||||
|
||||
Name: hidapi-libusb
|
||||
Description: C Library for USB HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the libusb implementation.
|
||||
URL: https://github.com/libusb/hidapi
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lhidapi-libusb
|
||||
Cflags: -I${includedir}/hidapi
|
||||
|
||||
@@ -5,6 +5,7 @@ includedir=@includedir@
|
||||
|
||||
Name: hidapi
|
||||
Description: C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows.
|
||||
URL: https://github.com/libusb/hidapi
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lhidapi
|
||||
Cflags: -I${includedir}/hidapi
|
||||
|
||||
+36
-9
@@ -5,7 +5,7 @@ file(READ "${PROJECT_ROOT}/VERSION" VERSION_STR)
|
||||
string(REGEX MATCH "^([0-9]+\\.[0-9]+\\.[0-9]+)(.*)" VERSION_STR "${VERSION_STR}")
|
||||
|
||||
set(VERSION "${CMAKE_MATCH_1}")
|
||||
set(VERSION_SUFFIX "${CMAKE_MATCH_2}")
|
||||
string(STRIP "${CMAKE_MATCH_2}" VERSION_SUFFIX)
|
||||
#
|
||||
|
||||
project(hidapi VERSION "${VERSION}" LANGUAGES C)
|
||||
@@ -15,17 +15,38 @@ project(hidapi VERSION "${VERSION}" LANGUAGES C)
|
||||
if(NOT DEFINED BUILD_SHARED_LIBS)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
endif()
|
||||
if(NOT DEFINED HIDAPI_WITH_HIDRAW)
|
||||
set(HIDAPI_WITH_HIDRAW ON)
|
||||
endif()
|
||||
if(NOT DEFINED HIDAPI_WITH_LIBUSB)
|
||||
set(HIDAPI_WITH_LIBUSB ON)
|
||||
endif()
|
||||
if(NOT DEFINED HIDAPI_INSTALL_TARGETS)
|
||||
set(HIDAPI_INSTALL_TARGETS OFF)
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
# Helper(s)
|
||||
|
||||
function(hidapi_configure_pc PC_IN_FILE)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pc")
|
||||
|
||||
set(VERSION "${VERSION}${VERSION_SUFFIX}")
|
||||
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
set(exec_prefix "\${prefix}")
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
||||
set(libdir "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
else()
|
||||
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
|
||||
get_filename_component(PC_IN_FILENAME "${PC_IN_FILE}" NAME_WE)
|
||||
set(PC_FILE "${CMAKE_CURRENT_BINARY_DIR}/pc/${PC_IN_FILENAME}.pc")
|
||||
configure_file("${PC_IN_FILE}" "${PC_FILE}" @ONLY)
|
||||
|
||||
install(FILES "${PC_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
|
||||
endfunction()
|
||||
|
||||
# The library
|
||||
|
||||
@@ -42,15 +63,21 @@ if(WIN32)
|
||||
elseif(APPLE)
|
||||
add_subdirectory("${PROJECT_ROOT}/mac" mac)
|
||||
else()
|
||||
if(NOT DEFINED HIDAPI_WITH_LIBUSB)
|
||||
set(HIDAPI_WITH_LIBUSB ON)
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
if(HIDAPI_WITH_HIDRAW)
|
||||
if(NOT DEFINED HIDAPI_WITH_HIDRAW OR HIDAPI_WITH_HIDRAW)
|
||||
add_subdirectory("${PROJECT_ROOT}/linux" linux)
|
||||
endif()
|
||||
set(HIDAPI_LIBNAME_VERBOSE ON)
|
||||
else()
|
||||
set(HIDAPI_WITH_LIBUSB ON)
|
||||
set(HIDAPI_LIBNAME_VERBOSE OFF)
|
||||
endif()
|
||||
if(HIDAPI_WITH_LIBUSB)
|
||||
add_subdirectory("${PROJECT_ROOT}/libusb" libusb)
|
||||
elseif(NOT TARGET hidapi_hidraw)
|
||||
message(FATAL_ERROR "Select at least one option to build: HIDAPI_WITH_LIBUSB or HIDAPI_WITH_HIDRAW")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -24,4 +24,6 @@ if(HIDAPI_INSTALL_TARGETS)
|
||||
)
|
||||
endif()
|
||||
|
||||
hidapi_configure_pc("${PROJECT_ROOT}/pc/hidapi.pc.in")
|
||||
|
||||
add_library(hidapi ALIAS hidapi_winapi)
|
||||
|
||||
Reference in New Issue
Block a user