1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2# 3# Copyright 2024 Google LLC 4# 5# Licensed under the Apache License v2.0 with LLVM Exceptions (the "License"); 6# you may not use this file except in compliance with the License. You may 7# obtain a copy of the License at 8# 9# https://llvm.org/LICENSE.txt 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations under 15# the License. 16# 17# Author: Giuliano Procida 18 19#[=======================================================================[.rst: 20FindLinuxUAPI 21------------- 22 23Finds the Linux UAPI headers. 24 25Result Variables 26^^^^^^^^^^^^^^^^ 27 28This will define the following variables: 29 30``LinuxUAPI_FOUND`` 31 True if the system has the Linux UAPI headers. 32``LinuxUAPI_INCLUDE_DIR`` 33 The Linux UAPI include directory. 34``LinuxUAPI_VERSION`` 35 The version of the Linux UAPI headers which were found. 36 37#]=======================================================================] 38 39find_path( 40 LinuxUAPI_INCLUDE_DIR 41 linux/version.h 42) 43mark_as_advanced(LinuxUAPI_INCLUDE_DIR) 44 45if(LinuxUAPI_INCLUDE_DIR) 46 file(READ "${LinuxUAPI_INCLUDE_DIR}/linux/version.h" _version_header) 47 string(REGEX REPLACE ".*#define LINUX_VERSION_MAJOR ([0-9]+).*#define LINUX_VERSION_PATCHLEVEL ([0-9]+).*#define LINUX_VERSION_SUBLEVEL ([0-9]+).*" "\\1.\\2.\\3" LinuxUAPI_VERSION "${_version_header}") 48endif() 49 50include(FindPackageHandleStandardArgs) 51find_package_handle_standard_args( 52 LinuxUAPI 53 REQUIRED_VARS LinuxUAPI_INCLUDE_DIR 54 VERSION_VAR LinuxUAPI_VERSION 55) 56