1# 2# Copyright (c) 2023, The OpenThread Authors. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# 2. Redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution. 12# 3. Neither the name of the copyright holder nor the 13# names of its contributors may be used to endorse or promote products 14# derived from this software without specific prior written permission. 15# 16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26# POSSIBILITY OF SUCH DAMAGE. 27# 28 29#[=======================================================================[.rst: 30FindExampleRcpVendorDeps 31------------------------ 32 33This file provides a reference for how to implement an RCP vendor 34dependency CMake module to resolve external libraries and header 35files used by a vendor implementation in the posix library. 36 37The name of this file and the name of the targets it defines are 38conventionally related. For the purpose of this reference, targets 39will be based off of the identifier "ExampleRcpVendorDeps". 40 41For more information about package resolution using CMake find modules, 42reference the cmake-developer documentation. 43 44Imported Targets 45^^^^^^^^^^^^^^^^ 46 47This module provides the following imported targets, if found: 48 49``ExampleRcpVendorDeps::ExampleRcpVendorDeps`` 50 RCP vendor interface library dependencies 51 52Result Variables 53^^^^^^^^^^^^^^^^ 54 55This will define the following variables: 56 57``ExampleRcpVendorDeps_FOUND`` 58 True if the system has all of the required external dependencies 59``ExampleRcpVendorDeps_INCLUDE_DIRS`` 60 Include directories needed by vendor interface 61``ExampleRcpVendorDeps_LIBRARIES`` 62 Libraries needed by vendor interface 63 64Cache Variables 65^^^^^^^^^^^^^^^ 66 67Vendors modules may configure various cache variables 68while resolving dependencies: 69 70``Dependency0_INCLUDE_DIR`` 71 The directory containing include files for dependency 0 72``Dependency0_LIBRARY`` 73 The path to the library containing symbols for dependency 0 74``Dependency1_INCLUDE_DIR`` 75 The directory containing include files for dependency 1 76``Dependency1_LIBRARY`` 77 The path to the library containing symbols for dependency 1 78 79#]=======================================================================] 80 81include(FindPackageHandleStandardArgs) 82 83find_path(Dependency0_INCLUDE_DIR 84 NAMES example0/example.h 85 PATH ${EXAMPLES_ROOT}/include 86) 87 88find_library(Dependency0_LIBRARY 89 NAMES example0 90 PATH ${EXAMPLES_ROOT}/lib 91) 92 93find_path(Dependency1_INCLUDE_DIR 94 NAMES example1/example.h 95 PATH ${EXAMPLES_ROOT}/include 96) 97 98find_library(Dependency1_LIBRARY 99 NAMES example1 100 PATH ${EXAMPLES_ROOT}/lib 101) 102 103find_package_handle_standard_args(ExampleRcpVendorDeps 104 FOUND_VAR ExampleRcpVendorDeps_FOUND 105 REQUIRED_VARS Dependency0_INCLUDE_DIR Dependency0_LIBRARY Dependency1_INCLUDE_DIR Dependency1_LIBRARY 106) 107 108if(ExampleRcpVendorDeps_FOUND AND NOT ExampleRcpVendorDeps::ExampleRcpVendorDeps) 109 set(ExampleRcpVendorDeps_INCLUDE_DIRS ${Dependency0_INCLUDE_DIR} ${Dependency1_INCLUDE_DIR}) 110 set(ExampleRcpVendorDeps_LIBRARIES ${Dependency0_LIBRARY} ${Dependency1_LIBRARY}) 111 112 add_library(ExampleRcpVendorDeps::ExampleRcpVendorDeps UNKNOWN IMPORTED) 113 set_target_properties(ExampleRcpVendorDeps::ExampleRcpVendorDeps PROPERTIES 114 IMPORTED_LOCATION "${ExampleRcpVendorDeps_LIBRARIES}" 115 INTERFACE_INCLUDE_DIRECTORIES "${ExampleRcpVendorDeps_INCLUDE_DIRS}" 116 ) 117 118 mark_as_advanced( 119 Dependency0_INCLUDE_DIR 120 Dependency0_LIBRARY 121 Dependency1_INCLUDE_DIR 122 Dependency1_LIBRARY 123 ) 124endif() 125 126