blob: b8709ac4f48c50cfe76376f58c8c5226bbf5c59d [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001#
2# SPDX-License-Identifier: BSD-3-Clause
3# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4#
5
6#
7# Common config options
8#
9arm_config_option(
10 NAME MAX_CPUS
11 HELP "Maximum number of CPUs supported by RMM"
12 TYPE STRING
13 DEFAULT 16)
14
15#
16# The RMM is mapped with 4K pages, and all RMM APIs use the same granularity.
17#
18arm_config_option(
19 NAME GRANULE_SIZE
20 HELP "Granule Size used by RMM"
21 TYPE STRING
22 DEFAULT 4096)
23
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000024#
25# RMM_MAX_GRANULES. Maximum number of granules supported.
26#
27arm_config_option(
28 NAME RMM_MAX_GRANULES
29 HELP "Maximum number of granules supported"
30 TYPE STRING
31 DEFAULT 0x0)
32
Soby Mathewb4c6df42022-11-09 11:13:29 +000033arm_config_option(
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020034 NAME RMM_NUM_PAGES_PER_STACK
35 HELP "Number of pages to use per CPU stack"
36 TYPE STRING
37 DEFAULT 5
38 ADVANCED)
39
40arm_config_option(
Soby Mathewb4c6df42022-11-09 11:13:29 +000041 NAME RMM_DOCS
42 HELP "RMM Documentation build"
43 TYPE BOOL
44 DEFAULT OFF)
45
46# TODO: Move to lib/arch once MbedTLS compilation is moved to build phase.
47arm_config_option(
48 NAME RMM_FPU_USE_AT_REL2
49 HELP "Enable Advanced SIMD support in RMM"
50 TYPE BOOL
51 DEFAULT ON
52 DEPENDS (RMM_ARCH STREQUAL aarch64)
53 ELSE OFF)
54
55#
56# Introduce a pseudo-library purely for applying flags to RMM's libraries.
57# This is applied to any targets created after this point.
58#
59
60add_library(rmm-common INTERFACE)
61
62target_compile_definitions(rmm-common
63 INTERFACE "$<$<CONFIG:Debug>:DEBUG>")
64
65if(MAX_CPUS EQUAL 0x0)
66 message(FATAL_ERROR "MAX_CPUS is not initialized")
67endif()
68
69target_compile_definitions(rmm-common
Javier Almansa Sobrinoc4ad5b02022-07-05 19:05:14 +010070 INTERFACE "MAX_CPUS=${MAX_CPUS}U")
Soby Mathewb4c6df42022-11-09 11:13:29 +000071
72if(NOT(GRANULE_SIZE EQUAL 4096))
73 message(FATAL_ERROR "GRANULE_SIZE is not initialized correctly")
74endif()
75
76target_compile_definitions(rmm-common
AlexeiFedorov52ec2fe2023-08-17 15:37:58 +010077 INTERFACE "GRANULE_SIZE=UL(${GRANULE_SIZE})")
Soby Mathewb4c6df42022-11-09 11:13:29 +000078
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000079if (RMM_MAX_GRANULES EQUAL 0x0)
80 message (FATAL_ERROR "RMM_MAX_GRANULES not configured")
81endif()
82
83target_compile_definitions(rmm-common
84 INTERFACE "RMM_MAX_GRANULES=U(${RMM_MAX_GRANULES})")
85
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020086target_compile_definitions(rmm-common
87 INTERFACE "RMM_NUM_PAGES_PER_STACK=UL(${RMM_NUM_PAGES_PER_STACK})")
88
Soby Mathewb4c6df42022-11-09 11:13:29 +000089if(RMM_FPU_USE_AT_REL2)
90 target_compile_definitions(rmm-common
91 INTERFACE "RMM_FPU_USE_AT_REL2=1")
92endif()
93
94#
95# Project name and version
96#
97target_compile_definitions(rmm-common
98 INTERFACE "NAME=\"${PROJECT_NAME}\"")
99
100target_compile_definitions(rmm-common
101 INTERFACE "VERSION=\"${PROJECT_VERSION}\"")
102
103#
104# Get git commit information
105#
106find_package(Git)
107if(GIT_FOUND)
108 execute_process(
109 COMMAND ${GIT_EXECUTABLE} describe --always --dirty --tags
110 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
111 OUTPUT_VARIABLE COMMIT_INFO
112 OUTPUT_STRIP_TRAILING_WHITESPACE
113 )
114endif()
115
116target_compile_definitions(rmm-common
117 INTERFACE "COMMIT_INFO=\"${COMMIT_INFO}\"")
118
119link_libraries(rmm-common)