Skip to content

Commit

Permalink
Merge branch 'rpavlik:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
esohns authored Jul 26, 2022
2 parents 7cf640c + 14094b5 commit c5c5adf
Show file tree
Hide file tree
Showing 23 changed files with 1,310 additions and 81 deletions.
3 changes: 3 additions & 0 deletions .cmake-format.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copyright 2019-2020, Collabora, Ltd.

SPDX-License-Identifier: BSL-1.0
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2022, Collabora, Ltd.

CMakeFiles/
.vscode/
10 changes: 7 additions & 3 deletions BoostTestTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
# CopyResourcesToBuildTree
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# 2009-2021, Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright 2021, Collabora, Ltd.
# Copyright 2009-2010, Iowa State University
#
# 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)
#
# SPDX-License-Identifier: BSL-1.0

if(__add_boost_test)
Expand All @@ -47,7 +49,9 @@ set(BOOST_TEST_TARGET_PREFIX "boosttest")
if(NOT Boost_FOUND)
find_package(Boost 1.34.0 QUIET)
endif()
if("${Boost_VERSION}0" LESS "1034000")
if("${Boost_VERSION}" MATCHES "[0-9][.].*")
# we are OK
elseif("${Boost_VERSION}0" LESS "1034000")
set(_shared_msg
"NOTE: boost::test-based targets and tests cannot "
"be added: boost >= 1.34.0 required but not found. "
Expand Down
2 changes: 1 addition & 1 deletion FindEGL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@ set(EGL_VERSION_STRING ${EGL_VERSION})
include(FeatureSummary)
set_package_properties(EGL PROPERTIES
URL "https://www.khronos.org/egl/"
DESCRIPTION "A platform-agnostic mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES and OpenVG."
DESCRIPTION "A platform-independent mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES and OpenVG."
)
26 changes: 14 additions & 12 deletions FindHIDAPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
# ``HIDAPI_LIBRARIES``
#
# Original Author:
# 2009-2010, 2019 Ryan Pavlik <[email protected]> <[email protected]>
# 2009-2021 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
#
# Copyright 2009-2010, Iowa State University
# Copyright 2019, Collabora, Ltd.
# Copyright 2019-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -72,17 +72,19 @@ if(NOT HIDAPI_FIND_COMPONENTS)
endif()

# Ask pkg-config for hints
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
# So pkg-config uses HIDAPI_ROOT_DIR too.
if(HIDAPI_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${HIDAPI_ROOT_DIR})
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
# So pkg-config uses HIDAPI_ROOT_DIR too.
if(HIDAPI_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${HIDAPI_ROOT_DIR})
endif()
pkg_check_modules(PC_HIDAPI_LIBUSB QUIET hidapi-libusb)
pkg_check_modules(PC_HIDAPI_HIDRAW QUIET hidapi-hidraw)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()
pkg_check_modules(PC_HIDAPI_LIBUSB QUIET hidapi-libusb)
pkg_check_modules(PC_HIDAPI_HIDRAW QUIET hidapi-hidraw)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()

# Actually search
Expand Down
27 changes: 16 additions & 11 deletions FindLibcheck.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Copyright 2019 Collabora, Ltd.
# Copyright 2019-2021 Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# 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 <[email protected]>
# 2019-2021 Ryan Pavlik <[email protected]>

#.rst:
# FindCheck
Expand Down Expand Up @@ -36,17 +38,20 @@ set(LIBCHECK_ROOT_DIR
"${LIBCHECK_ROOT_DIR}"
CACHE PATH "Root to search for libcheck")

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
# So pkg-config uses LIBCHECK_ROOT_DIR too.
if(LIBCHECK_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${LIBCHECK_ROOT_DIR})
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
# So pkg-config uses LIBCHECK_ROOT_DIR too.
if(LIBCHECK_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${LIBCHECK_ROOT_DIR})
endif()
pkg_check_modules(PC_LIBCHECK QUIET check)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()
pkg_check_modules(PC_LIBCHECK QUIET check)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()

find_path(
LIBCHECK_INCLUDE_DIR
NAMES check.h
Expand Down
147 changes: 147 additions & 0 deletions FindLibevent.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Copyright 2019-2022, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
# 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, 2021, 2022 Ryan Pavlik <[email protected]>

#[[.rst:
FindLibevent
---------------
Find the libevent library.
Components
^^^^^^^^^^
The following components are supported:
* ``core`` - core functionality
* ``extra`` - extra functions (http, dns, rpc)
* ``pthreads`` - multithreading (not avail on windows)
* ``openssl` - OpenSSL support
If none are specified, the default is ``core``.
Targets
^^^^^^^
If successful, the following imported targets are created, based on selected/found components
* ``Libevent::core``
* ``Libevent::extra``
* ``Libevent::pthreads``
* ``Libevent::openssl``
Cache variables
^^^^^^^^^^^^^^^
The following cache variable may also be set to assist/control the operation of this module:
``Libevent_ROOT_DIR``
The root to search for libevent.
#]]

set(Libevent_ROOT_DIR
"${Libevent_ROOT_DIR}"
CACHE PATH "Root to search for libevent")

if(NOT Libevent_FIND_COMPONENTS)
set(Libevent_FIND_COMPONENTS core)
endif()
# Todo: handle in-tree/fetch-content builds?

if(NOT LIBEVENT_FOUND)
# Look for a CMake config file
find_package(Libevent QUIET NO_MODULE)
endif()

set(_known_components core extra openssl)
if(NOT WIN32)
list(APPEND _known_components pthreads)
endif()

set(_got_targets FALSE)
foreach(_component ${_known_components})
if(TARGET libevent::${_component})
set(Libevent_${_component}_FOUND TRUE)
set(Libevent_${_component}_LIBRARY libevent::${_component})
set(_got_targets TRUE)
endif()
endforeach()

if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
# So pkg-config uses Libevent_ROOT_DIR too.
if(Libevent_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${Libevent_ROOT_DIR})
endif()
foreach(_component ${_known_components})
pkg_check_modules(PC_Libevent_${_component} QUIET
libevent_${_component})
endforeach()
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()
endif()

find_path(
Libevent_INCLUDE_DIR
NAMES event2/event.h
PATHS ${Libevent_ROOT_DIR}
HINTS ${PC_Libevent_INCLUDE_DIRS} ${LIBEVENT_INCLUDE_DIRS}
PATH_SUFFIXES include)
foreach(_component ${_known_components})
find_library(
Libevent_${_component}_LIBRARY
NAMES event_${_component}
PATHS ${Libevent_ROOT_DIR}
HINTS ${PC_Libevent_${_component}_LIBRARY_DIRS}
PATH_SUFFIXES lib)
if(Libevent_${_component}_LIBRARY)
set(Libevent_${_component}_FOUND TRUE)
endif()
endforeach()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Libevent
REQUIRED_VARS Libevent_INCLUDE_DIR
HANDLE_COMPONENTS)
if(Libevent_FOUND)
foreach(_component ${_known_components})
mark_as_advanced(Libevent_${_component}_LIBRARY)
if(Libevent_${_component}_FOUND AND NOT TARGET Libevent::${_component})
if(TARGET ${Libevent_${_component}_LIBRARY})
# we want an alias
add_library(Libevent::${_component} ALIAS
${Libevent_${_component}_LIBRARY})
else()
# we want an imported target
add_library(Libevent::${_component} UNKNOWN IMPORTED)

set_target_properties(
Libevent::${_component}
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${Libevent_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION
${Libevent_${_component}_LIBRARY})
endif()
endif()
endforeach()
mark_as_advanced(Libevent_INCLUDE_DIR)
endif()
mark_as_advanced(Libevent_ROOT_DIR Libevent_LIBRT Libevent_LIBM)

include(FeatureSummary)
set_package_properties(
Libevent PROPERTIES
URL "https://libevent.org/"
DESCRIPTION "An event-notification library.")
14 changes: 9 additions & 5 deletions FindLibusb1.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# 2009-2021 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright 2009-2010, Iowa State University
# Copyright 2021, Collabora, Ltd
#
# SPDX-License-Identifier: BSL-1.0
#
# 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)
Expand Down Expand Up @@ -47,9 +49,11 @@ if(WIN32)
endif()
else()
set(_lib_suffixes)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBUSB1 libusb-1.0)
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBUSB1 QUIET libusb-1.0)
endif()
endif()
endif()

Expand Down
80 changes: 80 additions & 0 deletions FindONNXRuntime.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2021, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# 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:
# 2021 Moses Turner <[email protected]>
# 2021 Ryan Pavlik <[email protected]>

#.rst:
# FindONNXRuntime
# ---------------
#
# Find the ONNX runtime
#
# Targets
# ^^^^^^^
#
# If successful, the following import target is created.
#
# ``ONNXRuntime::ONNXRuntime``
#
# Cache variables
# ^^^^^^^^^^^^^^^
#
# The following cache variable may also be set to assist/control the operation of this module:
#
# ``ONNXRuntime_ROOT_DIR``
# The root to search for ONNX runtime.
#

include(FeatureSummary)
set_package_properties(
ONNXRuntime PROPERTIES
URL "https://onnxruntime.ai/"
DESCRIPTION "Machine learning runtime")

set(ONNXRuntime_ROOT_DIR
"${ONNXRuntime_ROOT_DIR}"
CACHE PATH "Root to search for ONNXRuntime")

find_package(PkgConfig)
pkg_check_modules(PC_ONNXRuntime QUIET libonnxruntime)

find_library(
ONNXRuntime_LIBRARY
NAMES onnxruntime
PATHS ${ONNXRuntime_ROOT_DIR}
PATH_SUFFIXES lib
HINTS ${PC_ONNXRuntime_LIBRARY_DIRS})
find_path(
ONNXRuntime_INCLUDE_DIR core/session/onnxruntime_cxx_api.h
PATHS ${ONNXRuntime_ROOT_DIR}
PATH_SUFFIXES onnxruntime include/onnxruntime
HINTS ${PC_ONNXRuntime_INCLUDE_DIRS})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
ONNXRuntime REQUIRED_VARS ONNXRuntime_INCLUDE_DIR ONNXRuntime_LIBRARY)

if(ONNXRuntime_FOUND)
set(ONNXRuntime_INCLUDE_DIRS ${ONNXRuntime_INCLUDE_DIR})
set(ONNXRuntime_LIBRARIES "${ONNXRuntime_LIBRARY}")
if(NOT TARGET ONNXRuntime::ONNXRuntime)
add_library(ONNXRuntime::ONNXRuntime UNKNOWN IMPORTED)
endif()
set_target_properties(
ONNXRuntime::ONNXRuntime PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${ONNXRuntime_INCLUDE_DIRS}")
set_target_properties(
ONNXRuntime::ONNXRuntime
PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${ONNXRuntime_LIBRARY}")
mark_as_advanced(ONNXRuntime_INCLUDE_DIRS ONNXRuntime_LIBRARY)
endif()

mark_as_advanced(ONNXRuntime_ROOT_DIR)
Loading

0 comments on commit c5c5adf

Please sign in to comment.