Kristofer Jonsson | 02eef5b | 2022-09-06 14:38:10 +0200 | [diff] [blame] | 1 | # |
Mikael Olsson | def7863 | 2024-04-24 12:50:05 +0200 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Kristofer Jonsson | 02eef5b | 2022-09-06 14:38:10 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the License); you may |
| 6 | # not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # www.apache.org/licenses/LICENSE-2.0 |
| 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. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | function(build_openamp PROJECT_SYSTEM) |
| 19 | set(PROJECT_PROCESSOR "arm") |
| 20 | set(PROJECT_MACHINE "cortexm") |
| 21 | |
| 22 | file(GLOB SRCS |
| 23 | # libmetal |
| 24 | libmetal/lib/*.c |
| 25 | libmetal/lib/system/${PROJECT_SYSTEM}/*.c |
| 26 | libmetal/lib/compiler/gcc/*.c |
| 27 | |
| 28 | # Extra sources |
| 29 | src/system/${PROJECT_SYSTEM}/${PROJECT_MACHINE}/*.c |
| 30 | |
| 31 | # OpenAMP |
Kristofer Jonsson | 02eef5b | 2022-09-06 14:38:10 +0200 | [diff] [blame] | 32 | openamp/lib/remoteproc/*.c |
| 33 | openamp/lib/rpmsg/*.c |
Kristofer Jonsson | 02eef5b | 2022-09-06 14:38:10 +0200 | [diff] [blame] | 34 | openamp/lib/virtio/*.c) |
| 35 | |
| 36 | add_library(openamp-${PROJECT_SYSTEM} STATIC |
| 37 | ${SRCS}) |
| 38 | |
| 39 | target_include_directories(openamp-${PROJECT_SYSTEM} |
| 40 | PUBLIC |
| 41 | ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_SYSTEM} |
| 42 | openamp/lib/include |
| 43 | src/system/${PROJECT_SYSTEM}) |
| 44 | |
| 45 | target_compile_definitions(openamp-${PROJECT_SYSTEM} PRIVATE |
| 46 | OPENAMP_VERSION_MAJOR=0 |
| 47 | OPENAMP_VERSION_MINOR=0 |
| 48 | OPENAMP_VERSION_PATCH=0 |
| 49 | OPENAMP_VERSION=0 |
Mikael Olsson | def7863 | 2024-04-24 12:50:05 +0200 | [diff] [blame] | 50 | VIRTIO_DRIVER_SUPPORT=1 |
| 51 | VIRTIO_DEVICE_SUPPORT=1 |
Kristofer Jonsson | 02eef5b | 2022-09-06 14:38:10 +0200 | [diff] [blame] | 52 | METAL_INTERNAL) |
| 53 | |
| 54 | target_link_libraries(openamp-${PROJECT_SYSTEM} PRIVATE |
| 55 | cmsis_device |
| 56 | $<$<STREQUAL:${PROJECT_SYSTEM},freertos>:freertos_kernel>) |
| 57 | |
Kristofer Jonsson | d88c1c5 | 2023-02-14 13:52:59 +0100 | [diff] [blame] | 58 | target_compile_options(openamp-${PROJECT_SYSTEM} PRIVATE |
Ledion Daja | 3698770 | 2023-04-27 13:09:23 +0200 | [diff] [blame] | 59 | -Wno-cast-align |
Kristofer Jonsson | d88c1c5 | 2023-02-14 13:52:59 +0100 | [diff] [blame] | 60 | -Wno-unknown-pragmas |
Ledion Daja | 3698770 | 2023-04-27 13:09:23 +0200 | [diff] [blame] | 61 | -Wno-unused-but-set-variable |
Kristofer Jonsson | d88c1c5 | 2023-02-14 13:52:59 +0100 | [diff] [blame] | 62 | ) |
| 63 | |
Kristofer Jonsson | 02eef5b | 2022-09-06 14:38:10 +0200 | [diff] [blame] | 64 | # Generate libmetal headers |
| 65 | file(GLOB_RECURSE HDRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/libmetal/lib" "libmetal/lib/*.h") |
| 66 | |
| 67 | foreach(HDR ${HDRS}) |
| 68 | configure_file("libmetal/lib/${HDR}" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_SYSTEM}/metal/${HDR}") |
| 69 | endforeach() |
Kristofer Jonsson | d88c1c5 | 2023-02-14 13:52:59 +0100 | [diff] [blame] | 70 | |
Kristofer Jonsson | 02eef5b | 2022-09-06 14:38:10 +0200 | [diff] [blame] | 71 | endfunction() |
| 72 | |
| 73 | build_openamp(generic) |
| 74 | |
| 75 | if (TARGET freertos_kernel) |
| 76 | build_openamp(freertos) |
| 77 | endif() |