blob: f720cdf50da032f5d64c71b729e126c16ccc0276 [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# HAL library #
20#########################################################
21
22cmake_minimum_required(VERSION 3.15.6)
23
24set(HAL_TARGET hal)
25
26project(${HAL_TARGET}
27 DESCRIPTION "HAL library"
28 LANGUAGES C CXX)
29
30# Create static library
31add_library(${HAL_TARGET} STATIC)
32
33# Select which profile needs to be used:
34if (${CMAKE_CROSSCOMPILING})
35 set(PLATFORM_PROFILE bare-metal)
36else()
37 set(PLATFORM_PROFILE native)
38endif()
39
40set(PLATFORM_PROFILE_DIR profiles/${PLATFORM_PROFILE})
41
42## Common include directories - public
43target_include_directories(${HAL_TARGET}
44 PUBLIC
45 include
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000046 ${PLATFORM_PROFILE_DIR}/timer/include)
alexander31ae9f02022-02-10 16:15:54 +000047
48## Common sources for all profiles
49target_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 Sisodiaa1256e32022-02-23 14:40:45 +000054 ${PLATFORM_PROFILE_DIR}/timer/platform_timer.c)
alexander31ae9f02022-02-10 16:15:54 +000055
56if (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})
60endif ()
61
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000062if (NOT DEFINED PLATFORM_DRIVERS_DIR)
63 message(FATAL_ERROR "PLATFORM_DRIVERS_DIR need to be defined for this target")
64endif()
65
66
alexander31ae9f02022-02-10 16:15:54 +000067############################ bare-metal profile #############################
68if (PLATFORM_PROFILE STREQUAL bare-metal)
69
alexander31ae9f02022-02-10 16:15:54 +000070 ## 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
alexander31ae9f02022-02-10 16:15:54 +000093############################ native profile #############################
94elseif (PLATFORM_PROFILE STREQUAL native)
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000095
alexander31ae9f02022-02-10 16:15:54 +000096 ## 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 Sisodiad5679cc2022-03-03 16:30:07 +0000111else()
112 message(FATAL_ERROR "PLATFORM_PROFILE ${PLATFORM_PROFILE} not supported")
alexander31ae9f02022-02-10 16:15:54 +0000113endif()
114
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000115# Add platform_drivers target
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000116add_subdirectory(${PLATFORM_DRIVERS_DIR} ${CMAKE_BINARY_DIR}/platform_driver)
117
118# Link time library targets:
119target_link_libraries(${HAL_TARGET}
120 PUBLIC
121 log
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000122 platform_drivers)
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000123
alexander31ae9f02022-02-10 16:15:54 +0000124# Display status:
125message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
126message(STATUS "*******************************************************")
127message(STATUS "Library : " ${HAL_TARGET})
128message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
129message(STATUS "*******************************************************")