Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 1 | # |
Mikael Olsson | d4ad9e5 | 2024-02-07 11:22:26 +0100 | [diff] [blame^] | 2 | # SPDX-FileCopyrightText: Copyright 2020-2024 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Mikael Olsson | c1a418d | 2023-10-31 10:49:06 +0100 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 4 | # |
| 5 | # This program is free software and is provided to you under the terms of the |
| 6 | # GNU General Public License version 2 as published by the Free Software |
| 7 | # Foundation, and any use by you of this program is subject to the terms |
| 8 | # of such GNU licence. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program; if not, you can access it online at |
| 17 | # http://www.gnu.org/licenses/gpl-2.0.html. |
| 18 | # |
Davide Grohmann | f036423 | 2022-06-16 17:42:58 +0200 | [diff] [blame] | 19 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 20 | cmake_minimum_required(VERSION 3.0.2) |
| 21 | |
| 22 | # Set the project name and version |
| 23 | project("ethosu_kernel" VERSION 1.0) |
| 24 | |
| 25 | # Make sure KDIR is set |
| 26 | set(KDIR "" CACHE PATH "Path to Linux kernel sources") |
| 27 | if (NOT EXISTS ${KDIR}) |
| 28 | message(FATAL_ERROR "Can't build kernel module without KDIR.") |
| 29 | endif() |
| 30 | |
| 31 | # Depend on all h and c files |
| 32 | file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c" "*.h") |
| 33 | |
| 34 | # Build the kernel module |
| 35 | add_custom_target(kernel ALL |
Mikael Olsson | 47e9bd0 | 2023-11-14 10:43:30 +0100 | [diff] [blame] | 36 | COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR} CF=-Wsparse-error C=2 M=${CMAKE_CURRENT_SOURCE_DIR} CONFIG_ETHOSU=m CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} modules |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 37 | BYPRODUCTS ethosu.ko |
| 38 | DEPENDS ${SOURCES} Kbuild Kconfig |
| 39 | COMMENT "Building ethosu.ko" |
| 40 | VERBATIM) |
| 41 | |
| 42 | # Install the kernel object and headers |
| 43 | install(FILES ethosu.ko DESTINATION "modules") |
Mikael Olsson | d4ad9e5 | 2024-02-07 11:22:26 +0100 | [diff] [blame^] | 44 | install(FILES "include/uapi/ethosu.h" DESTINATION "include/uapi") |