mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
cmake: Add a new FindOpenHMD and FindLibcheck.
FindLibcheck name used because there is a supplied FindCheck.cmake from upstream that isn't as robust as we might want.
This commit is contained in:
parent
d1b76db672
commit
a06e8c237e
121
cmake/FindLibcheck.cmake
Normal file
121
cmake/FindLibcheck.cmake
Normal file
|
@ -0,0 +1,121 @@
|
|||
# Copyright 2019 Collabora, Ltd.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# Original Author:
|
||||
# 2019 Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
|
||||
#.rst:
|
||||
# FindCheck
|
||||
# ---------------
|
||||
#
|
||||
# Find the "Check" C unit testing framework.
|
||||
#
|
||||
# See https://libcheck.github.io
|
||||
#
|
||||
# The Debian package for this is called ``check``
|
||||
#
|
||||
# Targets
|
||||
# ^^^^^^^
|
||||
#
|
||||
# If successful, the following imported targets are created.
|
||||
#
|
||||
# ``libcheck::check``
|
||||
#
|
||||
# ``libcheck::subunit``
|
||||
#
|
||||
# Cache variables
|
||||
# ^^^^^^^^^^^^^^^
|
||||
#
|
||||
# The following cache variable may also be set to assist/control the operation of this module:
|
||||
#
|
||||
# ``LIBCHECK_ROOT_DIR``
|
||||
# The root to search for libcheck.
|
||||
|
||||
set(LIBCHECK_ROOT_DIR "${LIBCHECK_ROOT_DIR}" CACHE PATH "Root to search for libcheck")
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_LIBCHECK QUIET check)
|
||||
endif()
|
||||
find_path(LIBCHECK_INCLUDE_DIR
|
||||
NAMES
|
||||
check.h
|
||||
PATHS
|
||||
${LIBCHECK_ROOT_DIR}
|
||||
HINTS
|
||||
${PC_LIBCHECK_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES
|
||||
include
|
||||
)
|
||||
find_library(LIBCHECK_LIBRARY
|
||||
NAMES
|
||||
check_pic
|
||||
check
|
||||
PATHS
|
||||
${LIBCHECK_ROOT_DIR}
|
||||
HINTS
|
||||
${PC_LIBCHECK_LIBRARY_DIRS}
|
||||
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_LIBM m)
|
||||
|
||||
# include(CMakeFindDependencyMacro)
|
||||
# find_dependency(Threads)
|
||||
find_package(Threads QUIET)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libcheck
|
||||
REQUIRED_VARS
|
||||
LIBCHECK_INCLUDE_DIR
|
||||
LIBCHECK_LIBRARY
|
||||
LIBCHECK_SUBUNIT_LIBRARY
|
||||
THREADS_FOUND
|
||||
)
|
||||
if(LIBCHECK_FOUND)
|
||||
if(NOT TARGET libcheck::subunit)
|
||||
add_library(libcheck::subunit UNKNOWN IMPORTED)
|
||||
set_target_properties(libcheck::subunit PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBCHECK_INCLUDE_DIR}")
|
||||
set_target_properties(libcheck::subunit PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION ${LIBCHECK_SUBUNIT_LIBRARY})
|
||||
endif()
|
||||
if(NOT TARGET libcheck::check)
|
||||
add_library(libcheck::check UNKNOWN IMPORTED)
|
||||
|
||||
set_target_properties(libcheck::check PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBCHECK_INCLUDE_DIR}")
|
||||
set_target_properties(libcheck::check PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION ${LIBCHECK_LIBRARY})
|
||||
set_property(TARGET libcheck::check PROPERTY
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES libcheck::subunit Threads::Threads)
|
||||
|
||||
# if we found librt or libm, link them.
|
||||
if(LIBCHECK_LIBRT)
|
||||
set_property(TARGET libcheck::check APPEND PROPERTY
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES ${LIBCHECK_LIBRT})
|
||||
endif()
|
||||
if(LIBCHECK_LIBM)
|
||||
set_property(TARGET libcheck::check APPEND PROPERTY
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES ${LIBCHECK_LIBM})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
mark_as_advanced(LIBCHECK_INCLUDE_DIR LIBCHECK_LIBRARY LIBCHECK_SUBUNIT_LIBRARY)
|
||||
endif()
|
||||
mark_as_advanced(LIBCHECK_ROOT_DIR LIBCHECK_LIBRT LIBCHECK_LIBM)
|
124
cmake/FindOpenHMD.cmake
Normal file
124
cmake/FindOpenHMD.cmake
Normal file
|
@ -0,0 +1,124 @@
|
|||
# Copyright 2019 Collabora, Ltd.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# Original Author:
|
||||
# 2019 Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
|
||||
#.rst:
|
||||
# FindOpenHMD
|
||||
# ---------------
|
||||
#
|
||||
# Find the OpenHMD immersive computing interface library.
|
||||
#
|
||||
# See http://www.openhmd.net/
|
||||
#
|
||||
# Targets
|
||||
# ^^^^^^^
|
||||
#
|
||||
# If successful, the following import target is created.
|
||||
#
|
||||
# ``openhmd::openhmd``
|
||||
#
|
||||
# Cache variables
|
||||
# ^^^^^^^^^^^^^^^
|
||||
#
|
||||
# The following cache variable may also be set to assist/control the operation of this module:
|
||||
#
|
||||
# ``OPENHMD_ROOT_DIR``
|
||||
# The root to search for OpenHMD.
|
||||
|
||||
set(OPENHMD_ROOT_DIR "${OPENHMD_ROOT_DIR}" CACHE PATH "Root to search for OpenHMD")
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_OPENHMD QUIET openhmd)
|
||||
endif()
|
||||
find_path(OPENHMD_INCLUDE_DIR
|
||||
NAMES
|
||||
openhmd.h
|
||||
PATHS
|
||||
${OPENHMD_ROOT_DIR}
|
||||
HINTS
|
||||
${PC_OPENHMD_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES
|
||||
include
|
||||
openhmd
|
||||
include/openhmd
|
||||
)
|
||||
find_library(OPENHMD_LIBRARY
|
||||
NAMES
|
||||
openhmd
|
||||
PATHS
|
||||
${OPENHMD_ROOT_DIR}
|
||||
HINTS
|
||||
${PC_OPENHMD_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
)
|
||||
find_library(OPENHMD_LIBRT rt)
|
||||
find_library(OPENHMD_LIBM m)
|
||||
|
||||
find_package(Threads QUIET)
|
||||
|
||||
set(_ohmd_extra_deps)
|
||||
|
||||
set(OPENHMD_HIDAPI_TYPE)
|
||||
if(PC_OPENHMD_FOUND)
|
||||
# See if we need a particular hidapi.
|
||||
list(REMOVE_ITEM PC_OPENHMD_LIBRARIES openhmd)
|
||||
if(${PC_OPENHMD_LIBRARIES} MATCHES hidapi-libusb)
|
||||
set(OPENHMD_HIDAPI_TYPE libusb)
|
||||
find_package(HIDAPI QUIET COMPONENTS libusb)
|
||||
list(APPEND _ohmd_extra_deps HIDAPI_libusb_FOUND)
|
||||
elseif(${PC_OPENHMD_LIBRARIES} MATCHES hidapi-hidraw)
|
||||
set(OPENHMD_HIDAPI_TYPE hidraw)
|
||||
find_package(HIDAPI QUIET COMPONENTS hidraw)
|
||||
list(APPEND _ohmd_extra_deps HIDAPI_hidraw_FOUND)
|
||||
elseif(${PC_OPENHMD_LIBRARIES} MATCHES hidapi)
|
||||
# Undifferentiated
|
||||
set(OPENHMD_HIDAPI_TYPE undifferentiated)
|
||||
find_package(HIDAPI QUIET)
|
||||
list(APPEND _ohmd_extra_deps HIDAPI_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(OpenHMD
|
||||
REQUIRED_VARS
|
||||
OPENHMD_INCLUDE_DIR
|
||||
OPENHMD_LIBRARY
|
||||
THREADS_FOUND
|
||||
)
|
||||
if(OPENHMD_FOUND)
|
||||
set(OPENHMD_INCLUDE_DIRS ${OPENHMD_INCLUDE_DIR})
|
||||
set(OPENHMD_LIBRARIES ${OPENHMD_LIBRARY})
|
||||
if(NOT TARGET OpenHMD::OpenHMD)
|
||||
add_library(OpenHMD::OpenHMD UNKNOWN IMPORTED)
|
||||
endif()
|
||||
set_target_properties(OpenHMD::OpenHMD PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OPENHMD_INCLUDE_DIR}")
|
||||
set_target_properties(OpenHMD::OpenHMD PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION ${OPENHMD_LIBRARY})
|
||||
|
||||
set_property(TARGET OpenHMD::OpenHMD PROPERTY
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
|
||||
|
||||
if(${OPENHMD_HIDAPI_TYPE} STREQUAL libusb)
|
||||
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi-libusb)
|
||||
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi-libusb)
|
||||
elseif(${OPENHMD_HIDAPI_TYPE} STREQUAL hidraw)
|
||||
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi-hidraw)
|
||||
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi-hidraw)
|
||||
elseif(${OPENHMD_HIDAPI_TYPE} STREQUAL undifferentiated)
|
||||
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi)
|
||||
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi)
|
||||
endif()
|
||||
mark_as_advanced(OPENHMD_INCLUDE_DIR OPENHMD_LIBRARY)
|
||||
endif()
|
||||
mark_as_advanced(OPENHMD_ROOT_DIR OPENHMD_LIBRT OPENHMD_LIBM)
|
Loading…
Reference in a new issue