blob: cd3a2bcaa1d410325071950822519981c1100a33 [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2022 Arm Limited. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://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,
13# WITHOUT 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#########################################################
19# A generic (simple) platform support library #
20#########################################################
21
22cmake_minimum_required(VERSION 3.15.6)
23set(PLATFORM_DRIVERS_TARGET platform-drivers)
24project(${PLATFORM_DRIVERS_TARGET}
25 DESCRIPTION "Platform drivers library for a generic target"
26 LANGUAGES C CXX ASM)
27
28# 1. We should be cross-compiling (MPS3 taregt only runs Cortex-M targets)
29if (NOT ${CMAKE_CROSSCOMPILING})
30 message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.")
31endif()
32
33# 2. Set the platform cmake descriptor file
34if (NOT DEFINED PLATFORM_CMAKE_DESCRIPTOR_FILE)
35 set(PLATFORM_CMAKE_DESCRIPTOR_FILE
36 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/subsystem-profiles/simple_platform.cmake)
37endif()
38
39## Include the platform cmake descriptor file
40include(${PLATFORM_CMAKE_DESCRIPTOR_FILE})
41
42# 3. Generate sources:
43if (NOT DEFINED SOURCE_GEN_DIR)
44 set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp)
45endif()
46
47set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template)
48set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template)
49set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template)
50
51configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h")
52configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
53configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
54
55# If a TA config file is provided, we generate a settings file
56if (DEFINED TA_CONFIG_FILE)
57 include(${TA_CONFIG_FILE})
58 set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/timing_adapter_settings.template)
59 configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h")
60endif()
61
62# 4. Create static library
63add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
64
65## Include directories - public
66target_include_directories(${PLATFORM_DRIVERS_TARGET}
67 PUBLIC
68 include
69 ${SOURCE_GEN_DIR})
70
71## Platform sources
72target_sources(${PLATFORM_DRIVERS_TARGET}
73 PRIVATE
74 source/stubs_glcd.c
75 source/timer_simple_platform.c)
76
77## Platform component: uart
78target_sources(${PLATFORM_DRIVERS_TARGET}
79 PRIVATE
80 ${CMAKE_CURRENT_SOURCE_DIR}/../../components/uart_pl011/uart_pl011.c)
81target_include_directories(${PLATFORM_DRIVERS_TARGET}
82 PUBLIC
83 ${CMAKE_CURRENT_SOURCE_DIR}/../../components/uart_pl011/include)
84
85## Compile defs
86target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
87 PUBLIC
88 ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ}
89 $<$<BOOL:TA_CONFIG_FILE>:TIMING_ADAPTER_AVAILABLE>)
90
91target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
92 cmsis_device
93 log)
94
95# 6 Display status:
96message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
97message(STATUS "*******************************************************")
98message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
99message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
100message(STATUS "*******************************************************")