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 | # HAL library # |
| 20 | ######################################################### |
| 21 | |
| 22 | cmake_minimum_required(VERSION 3.15.6) |
| 23 | |
| 24 | set(HAL_TARGET hal) |
| 25 | |
| 26 | project(${HAL_TARGET} |
| 27 | DESCRIPTION "HAL library" |
| 28 | LANGUAGES C CXX) |
| 29 | |
| 30 | # Create static library |
| 31 | add_library(${HAL_TARGET} STATIC) |
| 32 | |
| 33 | # Select which profile needs to be used: |
| 34 | if (${CMAKE_CROSSCOMPILING}) |
| 35 | set(PLATFORM_PROFILE bare-metal) |
| 36 | else() |
| 37 | set(PLATFORM_PROFILE native) |
| 38 | endif() |
| 39 | |
| 40 | set(PLATFORM_PROFILE_DIR profiles/${PLATFORM_PROFILE}) |
| 41 | |
| 42 | ## Common include directories - public |
| 43 | target_include_directories(${HAL_TARGET} |
| 44 | PUBLIC |
| 45 | include |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 46 | ${PLATFORM_PROFILE_DIR}/timer/include) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 47 | |
| 48 | ## Common sources for all profiles |
| 49 | target_sources(${HAL_TARGET} |
| 50 | PRIVATE |
| 51 | hal.c |
| 52 | ${PLATFORM_PROFILE_DIR}/data_presentation/data_psn.c |
| 53 | ${PLATFORM_PROFILE_DIR}/data_acquisition/data_acq.c |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 54 | ${PLATFORM_PROFILE_DIR}/timer/platform_timer.c) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 55 | |
| 56 | if (DEFINED VERIFY_TEST_OUTPUT) |
| 57 | message(STATUS "Test output verification flag is: ${VERIFY_TEST_OUTPUT}") |
| 58 | target_compile_definitions(${HAL_TARGET} PUBLIC |
| 59 | VERIFY_TEST_OUTPUT=${VERIFY_TEST_OUTPUT}) |
| 60 | endif () |
| 61 | |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 62 | if (NOT DEFINED PLATFORM_DRIVERS_DIR) |
| 63 | message(FATAL_ERROR "PLATFORM_DRIVERS_DIR need to be defined for this target") |
| 64 | endif() |
| 65 | |
| 66 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 67 | ############################ bare-metal profile ############################# |
| 68 | if (PLATFORM_PROFILE STREQUAL bare-metal) |
| 69 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 70 | ## Additional include directories - private |
| 71 | target_include_directories(${HAL_TARGET} |
| 72 | PRIVATE |
| 73 | ${PLATFORM_PROFILE_DIR}/data_presentation/lcd/include) |
| 74 | |
| 75 | ## Additional sources - public |
| 76 | target_sources(${HAL_TARGET} |
| 77 | PUBLIC |
| 78 | ${PLATFORM_PROFILE_DIR}/bsp/retarget.c) |
| 79 | |
| 80 | ## Additional sources - private |
| 81 | target_sources(${HAL_TARGET} |
| 82 | PRIVATE |
| 83 | ${PLATFORM_PROFILE_DIR}/data_presentation/lcd/lcd_img.c) |
| 84 | |
| 85 | ## Compile definition: |
| 86 | target_compile_definitions(${HAL_TARGET} |
| 87 | PUBLIC |
| 88 | PLATFORM_HAL=PLATFORM_CORTEX_M_BAREMETAL) |
| 89 | |
| 90 | # Add dependencies for platform_driver first, in case they are needed by it. |
| 91 | add_subdirectory(cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device) |
| 92 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 93 | ############################ native profile ############################# |
| 94 | elseif (PLATFORM_PROFILE STREQUAL native) |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 95 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 96 | ## Additional include directories - private |
| 97 | target_include_directories(${HAL_TARGET} |
| 98 | PRIVATE |
| 99 | ${PLATFORM_PROFILE_DIR}/data_presentation/log/include) |
| 100 | |
| 101 | ## Additional sources - private |
| 102 | target_sources(${HAL_TARGET} |
| 103 | PRIVATE |
| 104 | ${PLATFORM_PROFILE_DIR}/data_presentation/log/log.c) |
| 105 | |
| 106 | ## Compile definition: |
| 107 | target_compile_definitions(${HAL_TARGET} |
| 108 | PUBLIC |
| 109 | PLATFORM_HAL=PLATFORM_UNKNOWN_LINUX_OS |
| 110 | ACTIVATION_BUF_SRAM_SZ=0) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 111 | else() |
| 112 | message(FATAL_ERROR "PLATFORM_PROFILE ${PLATFORM_PROFILE} not supported") |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 113 | endif() |
| 114 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 115 | # Add platform_drivers target |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 116 | add_subdirectory(${PLATFORM_DRIVERS_DIR} ${CMAKE_BINARY_DIR}/platform_driver) |
| 117 | |
| 118 | # Link time library targets: |
| 119 | target_link_libraries(${HAL_TARGET} |
| 120 | PUBLIC |
| 121 | log |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 122 | platform_drivers) |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 123 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 124 | # Display status: |
| 125 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 126 | message(STATUS "*******************************************************") |
| 127 | message(STATUS "Library : " ${HAL_TARGET}) |
| 128 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR}) |
| 129 | message(STATUS "*******************************************************") |