mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
cmake: Update scripts from shared module repo.
This commit is contained in:
parent
9a398b7de5
commit
72662d91c1
10
cmake/.cmake-format.json
Normal file
10
cmake/.cmake-format.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"tab_size": 4,
|
||||||
|
"dangle_parens": false,
|
||||||
|
"line_ending": "unix",
|
||||||
|
"command_case": "canonical",
|
||||||
|
"keyword_case": "upper",
|
||||||
|
"first_comment_is_literal": true,
|
||||||
|
"literal_comment_pattern": "(^[.]rst)|(#+)",
|
||||||
|
"enable_markup": false
|
||||||
|
}
|
|
@ -23,7 +23,7 @@
|
||||||
#
|
#
|
||||||
# IMPORTED Targets
|
# IMPORTED Targets
|
||||||
# ^^^^^^^^^^^^^^^^
|
# ^^^^^^^^^^^^^^^^
|
||||||
|
#
|
||||||
# This module defines :prop_tgt:`IMPORTED` target ``HIDAPI::hidapi`` (in all cases or
|
# This module defines :prop_tgt:`IMPORTED` target ``HIDAPI::hidapi`` (in all cases or
|
||||||
# if no components specified), ``HIDAPI::hidapi-libusb`` (if you requested the libusb component),
|
# if no components specified), ``HIDAPI::hidapi-libusb`` (if you requested the libusb component),
|
||||||
# and ``HIDAPI::hidapi-hidraw`` (if you requested the hidraw component),
|
# and ``HIDAPI::hidapi-hidraw`` (if you requested the hidraw component),
|
||||||
|
@ -50,7 +50,9 @@
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
set(HIDAPI_ROOT_DIR "${HIDAPI_ROOT_DIR}" CACHE PATH "Root to search for HIDAPI")
|
set(HIDAPI_ROOT_DIR
|
||||||
|
"${HIDAPI_ROOT_DIR}"
|
||||||
|
CACHE PATH "Root to search for HIDAPI")
|
||||||
|
|
||||||
# Clean up components
|
# Clean up components
|
||||||
if(HIDAPI_FIND_COMPONENTS)
|
if(HIDAPI_FIND_COMPONENTS)
|
||||||
|
@ -84,40 +86,32 @@ if(PKG_CONFIG_FOUND)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Actually search
|
# Actually search
|
||||||
find_library(HIDAPI_UNDECORATED_LIBRARY
|
find_library(
|
||||||
|
HIDAPI_UNDECORATED_LIBRARY
|
||||||
NAMES hidapi
|
NAMES hidapi
|
||||||
PATHS
|
PATHS "${HIDAPI_ROOT_DIR}"
|
||||||
"${HIDAPI_ROOT_DIR}"
|
PATH_SUFFIXES lib)
|
||||||
PATH_SUFFIXES
|
|
||||||
lib)
|
|
||||||
|
|
||||||
find_library(HIDAPI_LIBUSB_LIBRARY
|
find_library(
|
||||||
|
HIDAPI_LIBUSB_LIBRARY
|
||||||
NAMES hidapi hidapi-libusb
|
NAMES hidapi hidapi-libusb
|
||||||
PATHS
|
PATHS "${HIDAPI_ROOT_DIR}"
|
||||||
"${HIDAPI_ROOT_DIR}"
|
PATH_SUFFIXES lib
|
||||||
PATH_SUFFIXES
|
HINTS ${PC_HIDAPI_LIBUSB_LIBRARY_DIRS})
|
||||||
lib
|
|
||||||
HINTS
|
|
||||||
${PC_HIDAPI_LIBUSB_LIBRARY_DIRS})
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM MATCHES "Linux")
|
if(CMAKE_SYSTEM MATCHES "Linux")
|
||||||
find_library(HIDAPI_HIDRAW_LIBRARY
|
find_library(
|
||||||
|
HIDAPI_HIDRAW_LIBRARY
|
||||||
NAMES hidapi-hidraw
|
NAMES hidapi-hidraw
|
||||||
HINTS
|
HINTS ${PC_HIDAPI_HIDRAW_LIBRARY_DIRS})
|
||||||
${PC_HIDAPI_HIDRAW_LIBRARY_DIRS})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_path(HIDAPI_INCLUDE_DIR
|
find_path(
|
||||||
|
HIDAPI_INCLUDE_DIR
|
||||||
NAMES hidapi.h
|
NAMES hidapi.h
|
||||||
PATHS
|
PATHS "${HIDAPI_ROOT_DIR}"
|
||||||
"${HIDAPI_ROOT_DIR}"
|
PATH_SUFFIXES hidapi include include/hidapi
|
||||||
PATH_SUFFIXES
|
HINTS ${PC_HIDAPI_HIDRAW_INCLUDE_DIRS} ${PC_HIDAPI_LIBUSB_INCLUDE_DIRS})
|
||||||
hidapi
|
|
||||||
include
|
|
||||||
include/hidapi
|
|
||||||
HINTS
|
|
||||||
${PC_HIDAPI_HIDRAW_INCLUDE_DIRS}
|
|
||||||
${PC_HIDAPI_LIBUSB_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
find_package(Threads QUIET)
|
find_package(Threads QUIET)
|
||||||
|
|
||||||
|
@ -127,10 +121,14 @@ find_package(Threads QUIET)
|
||||||
set(HIDAPI_LIBRARY)
|
set(HIDAPI_LIBRARY)
|
||||||
|
|
||||||
# First, try to use a preferred backend if supplied
|
# First, try to use a preferred backend if supplied
|
||||||
if("${HIDAPI_FIND_COMPONENTS}" MATCHES "libusb" AND HIDAPI_LIBUSB_LIBRARY AND NOT HIDAPI_LIBRARY)
|
if("${HIDAPI_FIND_COMPONENTS}" MATCHES "libusb"
|
||||||
|
AND HIDAPI_LIBUSB_LIBRARY
|
||||||
|
AND NOT HIDAPI_LIBRARY)
|
||||||
set(HIDAPI_LIBRARY ${HIDAPI_LIBUSB_LIBRARY})
|
set(HIDAPI_LIBRARY ${HIDAPI_LIBUSB_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
if("${HIDAPI_FIND_COMPONENTS}" MATCHES "hidraw" AND HIDAPI_HIDRAW_LIBRARY AND NOT HIDAPI_LIBRARY)
|
if("${HIDAPI_FIND_COMPONENTS}" MATCHES "hidraw"
|
||||||
|
AND HIDAPI_HIDRAW_LIBRARY
|
||||||
|
AND NOT HIDAPI_LIBRARY)
|
||||||
set(HIDAPI_LIBRARY ${HIDAPI_HIDRAW_LIBRARY})
|
set(HIDAPI_LIBRARY ${HIDAPI_HIDRAW_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -149,10 +147,10 @@ endif()
|
||||||
# Determine if the various requested components are found.
|
# Determine if the various requested components are found.
|
||||||
###
|
###
|
||||||
set(_hidapi_component_required_vars)
|
set(_hidapi_component_required_vars)
|
||||||
|
|
||||||
foreach(_comp IN LISTS HIDAPI_FIND_COMPONENTS)
|
foreach(_comp IN LISTS HIDAPI_FIND_COMPONENTS)
|
||||||
if("${_comp}" STREQUAL "any")
|
if("${_comp}" STREQUAL "any")
|
||||||
list(APPEND _hidapi_component_required_vars
|
list(APPEND _hidapi_component_required_vars HIDAPI_INCLUDE_DIR
|
||||||
HIDAPI_INCLUDE_DIR
|
|
||||||
HIDAPI_LIBRARY)
|
HIDAPI_LIBRARY)
|
||||||
if(HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_LIBRARY}")
|
if(HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_LIBRARY}")
|
||||||
set(HIDAPI_any_FOUND TRUE)
|
set(HIDAPI_any_FOUND TRUE)
|
||||||
|
@ -162,7 +160,8 @@ foreach(_comp IN LISTS HIDAPI_FIND_COMPONENTS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
elseif("${_comp}" STREQUAL "libusb")
|
elseif("${_comp}" STREQUAL "libusb")
|
||||||
list(APPEND _hidapi_component_required_vars HIDAPI_INCLUDE_DIR HIDAPI_LIBUSB_LIBRARY)
|
list(APPEND _hidapi_component_required_vars HIDAPI_INCLUDE_DIR
|
||||||
|
HIDAPI_LIBUSB_LIBRARY)
|
||||||
if(HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_LIBUSB_LIBRARY}")
|
if(HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_LIBUSB_LIBRARY}")
|
||||||
set(HIDAPI_libusb_FOUND TRUE)
|
set(HIDAPI_libusb_FOUND TRUE)
|
||||||
mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBUSB_LIBRARY)
|
mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBUSB_LIBRARY)
|
||||||
|
@ -171,7 +170,8 @@ foreach(_comp IN LISTS HIDAPI_FIND_COMPONENTS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
elseif("${_comp}" STREQUAL "hidraw")
|
elseif("${_comp}" STREQUAL "hidraw")
|
||||||
list(APPEND _hidapi_component_required_vars HIDAPI_INCLUDE_DIR HIDAPI_HIDRAW_LIBRARY)
|
list(APPEND _hidapi_component_required_vars HIDAPI_INCLUDE_DIR
|
||||||
|
HIDAPI_HIDRAW_LIBRARY)
|
||||||
if(HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_HIDRAW_LIBRARY}")
|
if(HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_HIDRAW_LIBRARY}")
|
||||||
set(HIDAPI_hidraw_FOUND TRUE)
|
set(HIDAPI_hidraw_FOUND TRUE)
|
||||||
mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_HIDRAW_LIBRARY)
|
mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_HIDRAW_LIBRARY)
|
||||||
|
@ -190,18 +190,18 @@ unset(_comp)
|
||||||
# FPHSA call
|
# FPHSA call
|
||||||
###
|
###
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(HIDAPI
|
find_package_handle_standard_args(
|
||||||
REQUIRED_VARS
|
HIDAPI
|
||||||
${_hidapi_component_required_vars}
|
REQUIRED_VARS ${_hidapi_component_required_vars} THREADS_FOUND
|
||||||
THREADS_FOUND
|
|
||||||
HANDLE_COMPONENTS)
|
HANDLE_COMPONENTS)
|
||||||
if(HIDAPI_FOUND)
|
if(HIDAPI_FOUND)
|
||||||
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARY}")
|
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARY}")
|
||||||
set(HIDAPI_INCLUDE_DIRS "${HIDAPI_INCLUDE_DIR}")
|
set(HIDAPI_INCLUDE_DIRS "${HIDAPI_INCLUDE_DIR}")
|
||||||
if(NOT TARGET HIDAPI::hidapi)
|
if(NOT TARGET HIDAPI::hidapi)
|
||||||
add_library(HIDAPI::hidapi UNKNOWN IMPORTED)
|
add_library(HIDAPI::hidapi UNKNOWN IMPORTED)
|
||||||
set_target_properties(HIDAPI::hidapi PROPERTIES
|
set_target_properties(
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
HIDAPI::hidapi
|
||||||
|
PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_LOCATION "${HIDAPI_LIBRARY}"
|
IMPORTED_LOCATION "${HIDAPI_LIBRARY}"
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${HIDAPI_INCLUDE_DIR}"
|
INTERFACE_INCLUDE_DIRECTORIES "${HIDAPI_INCLUDE_DIR}"
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
||||||
|
@ -210,8 +210,9 @@ endif()
|
||||||
|
|
||||||
if(HIDAPI_libusb_FOUND AND NOT TARGET HIDAPI::hidapi-libusb)
|
if(HIDAPI_libusb_FOUND AND NOT TARGET HIDAPI::hidapi-libusb)
|
||||||
add_library(HIDAPI::hidapi-libusb UNKNOWN IMPORTED)
|
add_library(HIDAPI::hidapi-libusb UNKNOWN IMPORTED)
|
||||||
set_target_properties(HIDAPI::hidapi-libusb PROPERTIES
|
set_target_properties(
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
HIDAPI::hidapi-libusb
|
||||||
|
PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_LOCATION "${HIDAPI_LIBUSB_LIBRARY}"
|
IMPORTED_LOCATION "${HIDAPI_LIBUSB_LIBRARY}"
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${HIDAPI_INCLUDE_DIR}"
|
INTERFACE_INCLUDE_DIRECTORIES "${HIDAPI_INCLUDE_DIR}"
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
||||||
|
@ -219,8 +220,9 @@ endif()
|
||||||
|
|
||||||
if(HIDAPI_hidraw_FOUND AND NOT TARGET HIDAPI::hidapi-hidraw)
|
if(HIDAPI_hidraw_FOUND AND NOT TARGET HIDAPI::hidapi-hidraw)
|
||||||
add_library(HIDAPI::hidapi-hidraw UNKNOWN IMPORTED)
|
add_library(HIDAPI::hidapi-hidraw UNKNOWN IMPORTED)
|
||||||
set_target_properties(HIDAPI::hidapi-hidraw PROPERTIES
|
set_target_properties(
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
HIDAPI::hidapi-hidraw
|
||||||
|
PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_LOCATION "${HIDAPI_HIDRAW_LIBRARY}"
|
IMPORTED_LOCATION "${HIDAPI_HIDRAW_LIBRARY}"
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${HIDAPI_INCLUDE_DIR}"
|
INTERFACE_INCLUDE_DIRECTORIES "${HIDAPI_INCLUDE_DIR}"
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
# ``LIBCHECK_ROOT_DIR``
|
# ``LIBCHECK_ROOT_DIR``
|
||||||
# The root to search for libcheck.
|
# The root to search for libcheck.
|
||||||
|
|
||||||
set(LIBCHECK_ROOT_DIR "${LIBCHECK_ROOT_DIR}" CACHE PATH "Root to search for libcheck")
|
set(LIBCHECK_ROOT_DIR
|
||||||
|
"${LIBCHECK_ROOT_DIR}"
|
||||||
|
CACHE PATH "Root to search for libcheck")
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
|
@ -45,37 +47,24 @@ if(PKG_CONFIG_FOUND)
|
||||||
# Restore
|
# Restore
|
||||||
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
|
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
|
||||||
endif()
|
endif()
|
||||||
find_path(LIBCHECK_INCLUDE_DIR
|
find_path(
|
||||||
NAMES
|
LIBCHECK_INCLUDE_DIR
|
||||||
check.h
|
NAMES check.h
|
||||||
PATHS
|
PATHS ${LIBCHECK_ROOT_DIR}
|
||||||
${LIBCHECK_ROOT_DIR}
|
HINTS ${PC_LIBCHECK_INCLUDE_DIRS}
|
||||||
HINTS
|
PATH_SUFFIXES include)
|
||||||
${PC_LIBCHECK_INCLUDE_DIRS}
|
find_library(
|
||||||
PATH_SUFFIXES
|
LIBCHECK_LIBRARY
|
||||||
include
|
NAMES check_pic check
|
||||||
)
|
PATHS ${LIBCHECK_ROOT_DIR}
|
||||||
find_library(LIBCHECK_LIBRARY
|
HINTS ${PC_LIBCHECK_LIBRARY_DIRS}
|
||||||
NAMES
|
PATH_SUFFIXES lib)
|
||||||
check_pic
|
find_library(
|
||||||
check
|
LIBCHECK_SUBUNIT_LIBRARY
|
||||||
PATHS
|
NAMES subunit
|
||||||
${LIBCHECK_ROOT_DIR}
|
PATHS ${LIBCHECK_ROOT_DIR}
|
||||||
HINTS
|
HINTS ${PC_LIBCHECK_LIBRARY_DIRS}
|
||||||
${PC_LIBCHECK_LIBRARY_DIRS}
|
PATH_SUFFIXES lib)
|
||||||
PATH_SUFFIXES
|
|
||||||
lib
|
|
||||||
)
|
|
||||||
find_library(LIBCHECK_SUBUNIT_LIBRARY
|
|
||||||
NAMES
|
|
||||||
subunit
|
|
||||||
PATHS
|
|
||||||
${LIBCHECK_ROOT_DIR}
|
|
||||||
HINTS
|
|
||||||
${PC_LIBCHECK_LIBRARY_DIRS}
|
|
||||||
PATH_SUFFIXES
|
|
||||||
lib
|
|
||||||
)
|
|
||||||
find_library(LIBCHECK_LIBRT rt)
|
find_library(LIBCHECK_LIBRT rt)
|
||||||
find_library(LIBCHECK_LIBM m)
|
find_library(LIBCHECK_LIBM m)
|
||||||
|
|
||||||
|
@ -87,39 +76,42 @@ if(PC_LIBCHECK_FOUND AND "${PC_LIBCHECK_LIBRARIES}" MATCHES "subunit")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(Libcheck
|
find_package_handle_standard_args(
|
||||||
REQUIRED_VARS
|
Libcheck REQUIRED_VARS LIBCHECK_INCLUDE_DIR LIBCHECK_LIBRARY THREADS_FOUND)
|
||||||
LIBCHECK_INCLUDE_DIR
|
|
||||||
LIBCHECK_LIBRARY
|
|
||||||
THREADS_FOUND
|
|
||||||
)
|
|
||||||
if(LIBCHECK_FOUND)
|
if(LIBCHECK_FOUND)
|
||||||
if(NOT TARGET libcheck::check)
|
if(NOT TARGET libcheck::check)
|
||||||
add_library(libcheck::check UNKNOWN IMPORTED)
|
add_library(libcheck::check UNKNOWN IMPORTED)
|
||||||
|
|
||||||
set_target_properties(libcheck::check PROPERTIES
|
set_target_properties(
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBCHECK_INCLUDE_DIR}")
|
libcheck::check
|
||||||
set_target_properties(libcheck::check PROPERTIES
|
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBCHECK_INCLUDE_DIR}"
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_LOCATION ${LIBCHECK_LIBRARY})
|
IMPORTED_LOCATION ${LIBCHECK_LIBRARY}
|
||||||
set_property(TARGET libcheck::check PROPERTY
|
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
||||||
|
|
||||||
# if we found librt or libm, link them.
|
# if we found librt or libm, link them.
|
||||||
if(LIBCHECK_LIBRT)
|
if(LIBCHECK_LIBRT)
|
||||||
set_property(TARGET libcheck::check APPEND PROPERTY
|
set_property(
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBCHECK_LIBRT}")
|
TARGET libcheck::check
|
||||||
|
APPEND
|
||||||
|
PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBCHECK_LIBRT}")
|
||||||
endif()
|
endif()
|
||||||
if(LIBCHECK_LIBM)
|
if(LIBCHECK_LIBM)
|
||||||
set_property(TARGET libcheck::check APPEND PROPERTY
|
set_property(
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBCHECK_LIBM}")
|
TARGET libcheck::check
|
||||||
|
APPEND
|
||||||
|
PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBCHECK_LIBM}")
|
||||||
endif()
|
endif()
|
||||||
if(LIBCHECK_SUBUNIT_LIBRARY)
|
if(LIBCHECK_SUBUNIT_LIBRARY)
|
||||||
set_property(TARGET libcheck::check APPEND PROPERTY
|
set_property(
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBCHECK_SUBUNIT_LIBRARY}")
|
TARGET libcheck::check
|
||||||
|
APPEND
|
||||||
|
PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES
|
||||||
|
"${LIBCHECK_SUBUNIT_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
mark_as_advanced(LIBCHECK_INCLUDE_DIR LIBCHECK_LIBRARY LIBCHECK_SUBUNIT_LIBRARY)
|
mark_as_advanced(LIBCHECK_INCLUDE_DIR LIBCHECK_LIBRARY
|
||||||
|
LIBCHECK_SUBUNIT_LIBRARY)
|
||||||
endif()
|
endif()
|
||||||
mark_as_advanced(LIBCHECK_ROOT_DIR LIBCHECK_LIBRT LIBCHECK_LIBM)
|
mark_as_advanced(LIBCHECK_ROOT_DIR LIBCHECK_LIBRT LIBCHECK_LIBM)
|
||||||
|
|
|
@ -30,7 +30,9 @@
|
||||||
# ``OPENHMD_ROOT_DIR``
|
# ``OPENHMD_ROOT_DIR``
|
||||||
# The root to search for OpenHMD.
|
# The root to search for OpenHMD.
|
||||||
|
|
||||||
set(OPENHMD_ROOT_DIR "${OPENHMD_ROOT_DIR}" CACHE PATH "Root to search for OpenHMD")
|
set(OPENHMD_ROOT_DIR
|
||||||
|
"${OPENHMD_ROOT_DIR}"
|
||||||
|
CACHE PATH "Root to search for OpenHMD")
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
|
@ -44,42 +46,28 @@ if(PKG_CONFIG_FOUND)
|
||||||
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
|
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_path(OPENHMD_INCLUDE_DIR
|
find_path(
|
||||||
NAMES
|
OPENHMD_INCLUDE_DIR
|
||||||
openhmd.h
|
NAMES openhmd.h
|
||||||
PATHS
|
PATHS ${OPENHMD_ROOT_DIR}
|
||||||
${OPENHMD_ROOT_DIR}
|
HINTS ${PC_OPENHMD_INCLUDE_DIRS}
|
||||||
HINTS
|
PATH_SUFFIXES include openhmd include/openhmd)
|
||||||
${PC_OPENHMD_INCLUDE_DIRS}
|
find_library(
|
||||||
PATH_SUFFIXES
|
OPENHMD_LIBRARY
|
||||||
include
|
NAMES openhmd
|
||||||
openhmd
|
PATHS ${OPENHMD_ROOT_DIR} ${OPENHMD_ROOT_DIR}/build
|
||||||
include/openhmd
|
HINTS ${PC_OPENHMD_LIBRARY_DIRS}
|
||||||
)
|
PATH_SUFFIXES lib)
|
||||||
find_library(OPENHMD_LIBRARY
|
find_library(OPENHMD_LIBRT rt)
|
||||||
NAMES
|
find_library(OPENHMD_LIBM m)
|
||||||
openhmd
|
|
||||||
PATHS
|
|
||||||
${OPENHMD_ROOT_DIR}
|
|
||||||
${OPENHMD_ROOT_DIR}/build
|
|
||||||
HINTS
|
|
||||||
${PC_OPENHMD_LIBRARY_DIRS}
|
|
||||||
PATH_SUFFIXES
|
|
||||||
lib
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if(NOT WIN32)
|
|
||||||
find_library(OPENHMD_LIBRT rt)
|
|
||||||
find_library(OPENHMD_LIBM m)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(Threads QUIET)
|
find_package(Threads QUIET)
|
||||||
|
|
||||||
set(_ohmd_extra_deps)
|
set(_ohmd_extra_deps)
|
||||||
|
|
||||||
set(OPENHMD_HIDAPI_TYPE)
|
set(OPENHMD_HIDAPI_TYPE)
|
||||||
if(OPENHMD_LIBRARY AND "${OPENHMD_LIBRARY}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
if(OPENHMD_LIBRARY AND "${OPENHMD_LIBRARY}" MATCHES
|
||||||
|
"${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||||
# Looks like a static library
|
# Looks like a static library
|
||||||
if(PC_OPENHMD_FOUND)
|
if(PC_OPENHMD_FOUND)
|
||||||
# See if we need a particular hidapi.
|
# See if we need a particular hidapi.
|
||||||
|
@ -103,38 +91,38 @@ if(OPENHMD_LIBRARY AND "${OPENHMD_LIBRARY}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFF
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(OpenHMD
|
find_package_handle_standard_args(
|
||||||
REQUIRED_VARS
|
OpenHMD REQUIRED_VARS OPENHMD_INCLUDE_DIR OPENHMD_LIBRARY THREADS_FOUND)
|
||||||
OPENHMD_INCLUDE_DIR
|
|
||||||
OPENHMD_LIBRARY
|
|
||||||
THREADS_FOUND
|
|
||||||
)
|
|
||||||
if(OPENHMD_FOUND)
|
if(OPENHMD_FOUND)
|
||||||
set(OPENHMD_INCLUDE_DIRS "${OPENHMD_INCLUDE_DIR}")
|
set(OPENHMD_INCLUDE_DIRS "${OPENHMD_INCLUDE_DIR}")
|
||||||
set(OPENHMD_LIBRARIES "${OPENHMD_LIBRARY}")
|
set(OPENHMD_LIBRARIES "${OPENHMD_LIBRARY}")
|
||||||
if(NOT TARGET OpenHMD::OpenHMD)
|
if(NOT TARGET OpenHMD::OpenHMD)
|
||||||
add_library(OpenHMD::OpenHMD UNKNOWN IMPORTED)
|
add_library(OpenHMD::OpenHMD UNKNOWN IMPORTED)
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(OpenHMD::OpenHMD PROPERTIES
|
set_target_properties(
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${OPENHMD_INCLUDE_DIR}")
|
OpenHMD::OpenHMD
|
||||||
set_target_properties(OpenHMD::OpenHMD PROPERTIES
|
PROPERTIES IMPORTED_LOCATION "${OPENHMD_LIBRARY}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${OPENHMD_INCLUDE_DIR}"
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_LOCATION "${OPENHMD_LIBRARY}")
|
|
||||||
|
|
||||||
set_property(TARGET OpenHMD::OpenHMD PROPERTY
|
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
||||||
|
|
||||||
if("${OPENHMD_HIDAPI_TYPE}" STREQUAL libusb)
|
if("${OPENHMD_HIDAPI_TYPE}" STREQUAL libusb)
|
||||||
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
|
set_property(
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi-libusb)
|
TARGET OpenHMD::OpenHMD
|
||||||
|
APPEND
|
||||||
|
PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi-libusb)
|
||||||
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi-libusb)
|
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi-libusb)
|
||||||
elseif("${OPENHMD_HIDAPI_TYPE}" STREQUAL hidraw)
|
elseif("${OPENHMD_HIDAPI_TYPE}" STREQUAL hidraw)
|
||||||
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
|
set_property(
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi-hidraw)
|
TARGET OpenHMD::OpenHMD
|
||||||
|
APPEND
|
||||||
|
PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi-hidraw)
|
||||||
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi-hidraw)
|
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi-hidraw)
|
||||||
elseif("${OPENHMD_HIDAPI_TYPE}" STREQUAL undifferentiated)
|
elseif("${OPENHMD_HIDAPI_TYPE}" STREQUAL undifferentiated)
|
||||||
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
|
set_property(
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi)
|
TARGET OpenHMD::OpenHMD
|
||||||
|
APPEND
|
||||||
|
PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi)
|
||||||
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi)
|
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi)
|
||||||
endif()
|
endif()
|
||||||
mark_as_advanced(OPENHMD_INCLUDE_DIR OPENHMD_LIBRARY)
|
mark_as_advanced(OPENHMD_INCLUDE_DIR OPENHMD_LIBRARY)
|
||||||
|
|
|
@ -28,41 +28,34 @@
|
||||||
# ``CJSON_ROOT_DIR``
|
# ``CJSON_ROOT_DIR``
|
||||||
# The root to search for cJSON.
|
# The root to search for cJSON.
|
||||||
|
|
||||||
set(CJSON_ROOT_DIR "${CJSON_ROOT_DIR}" CACHE PATH "Root to search for cJSON")
|
set(CJSON_ROOT_DIR
|
||||||
|
"${CJSON_ROOT_DIR}"
|
||||||
|
CACHE PATH "Root to search for cJSON")
|
||||||
|
|
||||||
find_path(CJSON_INCLUDE_DIR
|
find_path(
|
||||||
NAMES
|
CJSON_INCLUDE_DIR
|
||||||
cjson/cJSON.h
|
NAMES cjson/cJSON.h
|
||||||
PATHS
|
PATHS ${CJSON_ROOT_DIR}
|
||||||
${CJSON_ROOT_DIR}
|
PATH_SUFFIXES include)
|
||||||
PATH_SUFFIXES
|
find_library(
|
||||||
include
|
CJSON_LIBRARY
|
||||||
)
|
NAMES cjson
|
||||||
find_library(CJSON_LIBRARY
|
PATHS ${CJSON_ROOT_DIR}
|
||||||
NAMES
|
PATH_SUFFIXES lib)
|
||||||
cjson
|
|
||||||
PATHS
|
|
||||||
${CJSON_ROOT_DIR}
|
|
||||||
PATH_SUFFIXES
|
|
||||||
lib
|
|
||||||
)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(cJSON
|
find_package_handle_standard_args(cJSON REQUIRED_VARS CJSON_INCLUDE_DIR
|
||||||
REQUIRED_VARS
|
CJSON_LIBRARY)
|
||||||
CJSON_INCLUDE_DIR
|
|
||||||
CJSON_LIBRARY
|
|
||||||
)
|
|
||||||
if(CJSON_FOUND)
|
if(CJSON_FOUND)
|
||||||
set(CJSON_INCLUDE_DIRS "${CJSON_INCLUDE_DIR}")
|
set(CJSON_INCLUDE_DIRS "${CJSON_INCLUDE_DIR}")
|
||||||
set(CJSON_LIBRARIES "${CJSON_LIBRARY}")
|
set(CJSON_LIBRARIES "${CJSON_LIBRARY}")
|
||||||
if(NOT TARGET cJSON::cJSON)
|
if(NOT TARGET cJSON::cJSON)
|
||||||
add_library(cJSON::cJSON UNKNOWN IMPORTED)
|
add_library(cJSON::cJSON UNKNOWN IMPORTED)
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(cJSON::cJSON PROPERTIES
|
set_target_properties(cJSON::cJSON PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${CJSON_INCLUDE_DIR}")
|
"${CJSON_INCLUDE_DIR}")
|
||||||
set_target_properties(cJSON::cJSON PROPERTIES
|
set_target_properties(
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
cJSON::cJSON PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_LOCATION "${CJSON_LIBRARY}")
|
IMPORTED_LOCATION "${CJSON_LIBRARY}")
|
||||||
mark_as_advanced(CJSON_INCLUDE_DIR CJSON_LIBRARY)
|
mark_as_advanced(CJSON_INCLUDE_DIR CJSON_LIBRARY)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in a new issue