The open source OpenXR runtime
at prediction-2 126 lines 3.8 kB view raw
1# Copyright 2021-2022, Collabora, Ltd. 2# 3# SPDX-License-Identifier: BSL-1.0 4# 5# Distributed under the Boost Software License, Version 1.0. 6# (See accompanying file LICENSE_1_0.txt or copy at 7# http://www.boost.org/LICENSE_1_0.txt) 8# 9# Original Author: 10# 2021-2022 Rylie Pavlik <rylie.pavlik@collabora.com> <rylie@ryliepavlik.com> 11 12#[[.rst: 13FindPercetto 14--------------- 15 16Find the Percetto C wrapper around the Perfetto tracing API. 17 18Targets 19^^^^^^^ 20 21If successful, the following imported targets are created. 22 23* ``percetto::percetto`` 24 25Cache variables 26^^^^^^^^^^^^^^^ 27 28The following cache variable may also be set to assist/control the operation of this module: 29 30``Percetto_ROOT_DIR`` 31 The root to search for Percetto. 32#]] 33 34set(Percetto_ROOT_DIR 35 "${Percetto_ROOT_DIR}" 36 CACHE PATH "Root to search for Percetto") 37 38include(FeatureSummary) 39set_package_properties( 40 Percetto PROPERTIES 41 URL "https://github.com/olvaffe/percetto/" 42 DESCRIPTION "A C wrapper around the C++ Perfetto tracing SDK.") 43 44include(FindPackageHandleStandardArgs) 45 46# See if it's being built in a current project. 47if(NOT Percetto_FOUND) 48 if(TARGET percetto::percetto) 49 # OK, good - this is what we wanted 50 elseif(TARGET Percetto::percetto) 51 # we now prefer lowercase 52 add_library(percetto::percetto INTERFACE IMPORTED) 53 set_target_properties( 54 percetto::percetto PROPERTIES INTERFACE_LINK_LIBRARIES 55 Percetto::percetto) 56 endif() 57 58 if(TARGET percetto::percetto) 59 set(Percetto_LIBRARY percetto::percetto) 60 find_package_handle_standard_args(Percetto 61 REQUIRED_VARS Percetto_LIBRARY) 62 return() 63 endif() 64endif() 65 66# See if we can find something made by android prefab (gradle), or exported by CMake 67find_package(Percetto QUIET CONFIG NAMES percetto Percetto) 68if(Percetto_FOUND) 69 find_package_handle_standard_args(Percetto CONFIG_MODE) 70 if(TARGET percetto::percetto) 71 # OK, good - this is what we wanted 72 elseif(TARGET Percetto::percetto) 73 # we now prefer lowercase 74 add_library(percetto::percetto INTERFACE IMPORTED) 75 set_target_properties( 76 percetto::percetto PROPERTIES INTERFACE_LINK_LIBRARIES 77 Percetto::percetto) 78 else() 79 message(FATAL_ERROR "assumptions failed") 80 endif() 81 return() 82endif() 83 84if(NOT ANDROID) 85 find_package(PkgConfig QUIET) 86 if(PKG_CONFIG_FOUND) 87 set(_old_prefix_path "${CMAKE_PREFIX_PATH}") 88 # So pkg-config uses Percetto_ROOT_DIR too. 89 if(Percetto_ROOT_DIR) 90 list(APPEND CMAKE_PREFIX_PATH ${Percetto_ROOT_DIR}) 91 endif() 92 pkg_check_modules(PC_percetto QUIET percetto) 93 # Restore 94 set(CMAKE_PREFIX_PATH "${_old_prefix_path}") 95 endif() 96endif() 97 98find_path( 99 Percetto_INCLUDE_DIR 100 NAMES percetto.h 101 PATHS ${Percetto_ROOT_DIR} 102 HINTS ${PC_percetto_INCLUDE_DIRS} 103 PATH_SUFFIXES include) 104 105find_library( 106 Percetto_LIBRARY 107 NAMES percetto 108 PATHS ${Percetto_ROOT_DIR} 109 HINTS ${PC_percetto_LIBRARY_DIRS} 110 PATH_SUFFIXES lib) 111 112find_package_handle_standard_args(Percetto REQUIRED_VARS Percetto_INCLUDE_DIR 113 Percetto_LIBRARY) 114if(Percetto_FOUND) 115 if(NOT TARGET percetto::percetto) 116 add_library(percetto::percetto UNKNOWN IMPORTED) 117 118 set_target_properties( 119 percetto::percetto 120 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Percetto_INCLUDE_DIR}" 121 IMPORTED_LINK_INTERFACE_LANGUAGES "C" 122 IMPORTED_LOCATION ${Percetto_LIBRARY}) 123 endif() 124 mark_as_advanced(Percetto_LIBRARY Percetto_INCLUDE_DIR) 125endif() 126mark_as_advanced(Percetto_ROOT_DIR)