1e5c31af7Sopenharmony_ci# Copyright 2018 The Amber Authors. 2e5c31af7Sopenharmony_ci# 3e5c31af7Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 4e5c31af7Sopenharmony_ci# you may not use this file except in compliance with the License. 5e5c31af7Sopenharmony_ci# You may obtain a copy of the License at 6e5c31af7Sopenharmony_ci# 7e5c31af7Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 8e5c31af7Sopenharmony_ci# 9e5c31af7Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 10e5c31af7Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 11e5c31af7Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e5c31af7Sopenharmony_ci# See the License for the specific language governing permissions and 13e5c31af7Sopenharmony_ci# limitations under the License. 14e5c31af7Sopenharmony_ci 15e5c31af7Sopenharmony_ci 16e5c31af7Sopenharmony_ci# Include this file to find Dawn and and set up compilation and linking. 17e5c31af7Sopenharmony_ci 18e5c31af7Sopenharmony_ci## Example usage: 19e5c31af7Sopenharmony_ci## 20e5c31af7Sopenharmony_ci## include(find_dawn.cmake) 21e5c31af7Sopenharmony_ci## # Set HAVE_DAWN to 1 if we have Dawn, and 0 otherwise. 22e5c31af7Sopenharmony_ci## add_definitions(-DHAVE_DAWN=$<BOOL:${Dawn_FOUND}>) 23e5c31af7Sopenharmony_ci## # Set up link dependencies. 24e5c31af7Sopenharmony_ci## if (${Dawn_FOUND}) 25e5c31af7Sopenharmony_ci## target_link_libraries(mylib Dawn::dawn_native) 26e5c31af7Sopenharmony_ci## endif() 27e5c31af7Sopenharmony_ci## 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ci# Exports these settings to the includer: 30e5c31af7Sopenharmony_ci# Boolean Dawn_FOUND indicates whether we found Dawn. 31e5c31af7Sopenharmony_ci# If Dawn was found, then library dependencies for Dawn::dawn and Dawn::dawn_native 32e5c31af7Sopenharmony_ci# will be set up. 33e5c31af7Sopenharmony_ciset(Dawn_FOUND FALSE) 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_ci# Setup via CMake setting variables: 36e5c31af7Sopenharmony_ci# 37e5c31af7Sopenharmony_ci# Separately specify the directory locations of the Dawn headers and 38e5c31af7Sopenharmony_ci# the dawn_native library. 39e5c31af7Sopenharmony_ci# 40e5c31af7Sopenharmony_ci# -DDawn_INCLUDE_DIR=<directory containing dawn/dawn_export.h> 41e5c31af7Sopenharmony_ci# -DDawn_GEN_INCLUDE_DIR=<directory containing dawn/dawn.h> 42e5c31af7Sopenharmony_ci# -DDawn_LIBRARY_DIR=<directory containing dawn_native library 43e5c31af7Sopenharmony_ci# e.g., libdawn_native.a> 44e5c31af7Sopenharmony_ci 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_cifind_path(Dawn_INCLUDE_DIR 47e5c31af7Sopenharmony_ci NAMES dawn/dawn_export.h 48e5c31af7Sopenharmony_ci PATHS 49e5c31af7Sopenharmony_ci "${Dawn_INCLUDE_DIR}" 50e5c31af7Sopenharmony_ci ) 51e5c31af7Sopenharmony_cifind_path(Dawn_GEN_INCLUDE_DIR 52e5c31af7Sopenharmony_ci NAMES dawn/dawn.h dawn/dawncpp.h 53e5c31af7Sopenharmony_ci PATHS 54e5c31af7Sopenharmony_ci "${Dawn_GEN_INCLUDE_DIR}" 55e5c31af7Sopenharmony_ci ) 56e5c31af7Sopenharmony_cifind_library(Dawn_LIBRARY 57e5c31af7Sopenharmony_ci NAMES dawn 58e5c31af7Sopenharmony_ci PATHS 59e5c31af7Sopenharmony_ci "${Dawn_LIBRARY_DIR}" 60e5c31af7Sopenharmony_ci ) 61e5c31af7Sopenharmony_cifind_library(Dawn_native_LIBRARY 62e5c31af7Sopenharmony_ci NAMES dawn_native 63e5c31af7Sopenharmony_ci PATHS 64e5c31af7Sopenharmony_ci "${Dawn_LIBRARY_DIR}" 65e5c31af7Sopenharmony_ci ) 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ciinclude(FindPackageHandleStandardArgs) 68e5c31af7Sopenharmony_cifind_package_handle_standard_args(Dawn 69e5c31af7Sopenharmony_ci DEFAULT_MSG 70e5c31af7Sopenharmony_ci Dawn_INCLUDE_DIR Dawn_GEN_INCLUDE_DIR 71e5c31af7Sopenharmony_ci Dawn_LIBRARY Dawn_native_LIBRARY 72e5c31af7Sopenharmony_ci ) 73e5c31af7Sopenharmony_ci 74e5c31af7Sopenharmony_ciif(${Dawn_FOUND} AND NOT TARGET Dawn::dawn) 75e5c31af7Sopenharmony_ci add_library(Dawn::dawn UNKNOWN IMPORTED) 76e5c31af7Sopenharmony_ci set_target_properties(Dawn::dawn PROPERTIES 77e5c31af7Sopenharmony_ci IMPORTED_LOCATION "${Dawn_LIBRARY}" 78e5c31af7Sopenharmony_ci INTERFACE_INCLUDE_DIRECTORIES "${Dawn_INCLUDE_DIR};${Dawn_GEN_INCLUDE_DIR}") 79e5c31af7Sopenharmony_ciendif() 80e5c31af7Sopenharmony_ciif(${Dawn_FOUND} AND NOT TARGET Dawn::dawn_native) 81e5c31af7Sopenharmony_ci add_library(Dawn::dawn_native UNKNOWN IMPORTED) 82e5c31af7Sopenharmony_ci set_target_properties(Dawn::dawn_native PROPERTIES 83e5c31af7Sopenharmony_ci IMPORTED_LOCATION "${Dawn_native_LIBRARY}" 84e5c31af7Sopenharmony_ci INTERFACE_INCLUDE_DIRECTORIES "${Dawn_INCLUDE_DIR};${Dawn_GEN_INCLUDE_DIR}") 85e5c31af7Sopenharmony_ciendif() 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ciif (${Dawn_FOUND}) 88e5c31af7Sopenharmony_ci message(STATUS "Amber: Using Dawn headers at ${Dawn_INCLUDE_DIR}") 89e5c31af7Sopenharmony_ci message(STATUS "Amber: Using Dawn generated headers at ${Dawn_GEN_INCLUDE_DIR}") 90e5c31af7Sopenharmony_ci message(STATUS "Amber: Using Dawn library ${Dawn_LIBRARY}") 91e5c31af7Sopenharmony_ci message(STATUS "Amber: Using Dawn native library ${Dawn_native_LIBRARY}") 92e5c31af7Sopenharmony_cielse() 93e5c31af7Sopenharmony_ci message(STATUS "Amber: Did not find Dawn") 94e5c31af7Sopenharmony_ciendif() 95