blob: c725069fb132f12d61de33aaf8972f48a83e9d91 [file] [log] [blame]
Kristofer Jonsson02eef5b2022-09-06 14:38:10 +02001#
Mikael Olssondef78632024-04-24 12:50:05 +02002# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kristofer Jonsson02eef5b2022-09-06 14:38:10 +02003# 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
18function(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 Jonsson02eef5b2022-09-06 14:38:10 +020032 openamp/lib/remoteproc/*.c
33 openamp/lib/rpmsg/*.c
Kristofer Jonsson02eef5b2022-09-06 14:38:10 +020034 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 Olssondef78632024-04-24 12:50:05 +020050 VIRTIO_DRIVER_SUPPORT=1
51 VIRTIO_DEVICE_SUPPORT=1
Kristofer Jonsson02eef5b2022-09-06 14:38:10 +020052 METAL_INTERNAL)
53
54 target_link_libraries(openamp-${PROJECT_SYSTEM} PRIVATE
55 cmsis_device
56 $<$<STREQUAL:${PROJECT_SYSTEM},freertos>:freertos_kernel>)
57
Kristofer Jonssond88c1c52023-02-14 13:52:59 +010058 target_compile_options(openamp-${PROJECT_SYSTEM} PRIVATE
Ledion Daja36987702023-04-27 13:09:23 +020059 -Wno-cast-align
Kristofer Jonssond88c1c52023-02-14 13:52:59 +010060 -Wno-unknown-pragmas
Ledion Daja36987702023-04-27 13:09:23 +020061 -Wno-unused-but-set-variable
Kristofer Jonssond88c1c52023-02-14 13:52:59 +010062 )
63
Kristofer Jonsson02eef5b2022-09-06 14:38:10 +020064 # 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 Jonssond88c1c52023-02-14 13:52:59 +010070
Kristofer Jonsson02eef5b2022-09-06 14:38:10 +020071endfunction()
72
73build_openamp(generic)
74
75if (TARGET freertos_kernel)
76 build_openamp(freertos)
77endif()