blob: 801c0c8d5395f55a39b2face0281757092748656 [file] [log] [blame]
Kristofer Jonsson02eef5b2022-09-06 14:38:10 +02001#
2# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
3#
4# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the License); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an AS IS BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19function(build_openamp PROJECT_SYSTEM)
20 set(PROJECT_PROCESSOR "arm")
21 set(PROJECT_MACHINE "cortexm")
22
23 file(GLOB SRCS
24 # libmetal
25 libmetal/lib/*.c
26 libmetal/lib/system/${PROJECT_SYSTEM}/*.c
27 libmetal/lib/compiler/gcc/*.c
28
29 # Extra sources
30 src/system/${PROJECT_SYSTEM}/${PROJECT_MACHINE}/*.c
31
32 # OpenAMP
33# openamp/lib/proxy/*.c
34 openamp/lib/remoteproc/*.c
35 openamp/lib/rpmsg/*.c
36# openamp/lib/service/*.c
37 openamp/lib/virtio/*.c)
38
39 add_library(openamp-${PROJECT_SYSTEM} STATIC
40 ${SRCS})
41
42 target_include_directories(openamp-${PROJECT_SYSTEM}
43 PUBLIC
44 ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_SYSTEM}
45 openamp/lib/include
46 src/system/${PROJECT_SYSTEM})
47
48 target_compile_definitions(openamp-${PROJECT_SYSTEM} PRIVATE
49 OPENAMP_VERSION_MAJOR=0
50 OPENAMP_VERSION_MINOR=0
51 OPENAMP_VERSION_PATCH=0
52 OPENAMP_VERSION=0
53 $<$<STREQUAL:${CMAKE_CXX_COMPILER_ID},ARMClang>:__ICCARM__>
54 METAL_INTERNAL)
55
56 target_link_libraries(openamp-${PROJECT_SYSTEM} PRIVATE
57 cmsis_device
58 $<$<STREQUAL:${PROJECT_SYSTEM},freertos>:freertos_kernel>)
59
60 # Generate libmetal headers
61 file(GLOB_RECURSE HDRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/libmetal/lib" "libmetal/lib/*.h")
62
63 foreach(HDR ${HDRS})
64 configure_file("libmetal/lib/${HDR}" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_SYSTEM}/metal/${HDR}")
65 endforeach()
66endfunction()
67
68build_openamp(generic)
69
70if (TARGET freertos_kernel)
71 build_openamp(freertos)
72endif()