alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 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 | |
| 22 | cmake_minimum_required(VERSION 3.15.6) |
| 23 | set(PLATFORM_DRIVERS_TARGET platform-drivers) |
| 24 | project(${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) |
| 29 | if (NOT ${CMAKE_CROSSCOMPILING}) |
| 30 | message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.") |
| 31 | endif() |
| 32 | |
| 33 | # 2. Set the platform cmake descriptor file |
| 34 | if (NOT DEFINED PLATFORM_CMAKE_DESCRIPTOR_FILE) |
| 35 | set(PLATFORM_CMAKE_DESCRIPTOR_FILE |
| 36 | ${CMAKE_CURRENT_SOURCE_DIR}/cmake/subsystem-profiles/simple_platform.cmake) |
| 37 | endif() |
| 38 | |
| 39 | ## Include the platform cmake descriptor file |
| 40 | include(${PLATFORM_CMAKE_DESCRIPTOR_FILE}) |
| 41 | |
| 42 | # 3. Generate sources: |
| 43 | if (NOT DEFINED SOURCE_GEN_DIR) |
| 44 | set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp) |
| 45 | endif() |
| 46 | |
| 47 | set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template) |
| 48 | set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template) |
| 49 | set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template) |
| 50 | |
| 51 | configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h") |
| 52 | configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h") |
| 53 | configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h") |
| 54 | |
| 55 | # If a TA config file is provided, we generate a settings file |
| 56 | if (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") |
| 60 | endif() |
| 61 | |
| 62 | # 4. Create static library |
| 63 | add_library(${PLATFORM_DRIVERS_TARGET} STATIC) |
| 64 | |
| 65 | ## Include directories - public |
| 66 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 67 | PUBLIC |
| 68 | include |
| 69 | ${SOURCE_GEN_DIR}) |
| 70 | |
| 71 | ## Platform sources |
| 72 | target_sources(${PLATFORM_DRIVERS_TARGET} |
| 73 | PRIVATE |
| 74 | source/stubs_glcd.c |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 75 | source/timer_simple_platform.c |
| 76 | source/platform_drivers.c) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 77 | |
| 78 | ## Platform component: uart |
| 79 | target_sources(${PLATFORM_DRIVERS_TARGET} |
| 80 | PRIVATE |
| 81 | ${CMAKE_CURRENT_SOURCE_DIR}/../../components/uart_pl011/uart_pl011.c) |
| 82 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 83 | PUBLIC |
| 84 | ${CMAKE_CURRENT_SOURCE_DIR}/../../components/uart_pl011/include) |
| 85 | |
| 86 | ## Compile defs |
| 87 | target_compile_definitions(${PLATFORM_DRIVERS_TARGET} |
| 88 | PUBLIC |
| 89 | ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ} |
| 90 | $<$<BOOL:TA_CONFIG_FILE>:TIMING_ADAPTER_AVAILABLE>) |
| 91 | |
| 92 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC |
| 93 | cmsis_device |
| 94 | log) |
| 95 | |
| 96 | # 6 Display status: |
| 97 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 98 | message(STATUS "*******************************************************") |
| 99 | message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET}) |
| 100 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR}) |
| 101 | message(STATUS "*******************************************************") |