1#
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
24arm_config_option(
25    NAME RMM_DOCS
26    HELP "RMM Documentation build"
27    TYPE BOOL
28    DEFAULT OFF)
29
30# TODO: Move to lib/arch once MbedTLS compilation is moved to build phase.
31arm_config_option(
32    NAME RMM_FPU_USE_AT_REL2
33    HELP "Enable Advanced SIMD support in RMM"
34    TYPE BOOL
35    DEFAULT ON
36    DEPENDS (RMM_ARCH STREQUAL aarch64)
37    ELSE OFF)
38
39#
40# Introduce a pseudo-library purely for applying flags to RMM's libraries.
41# This is applied to any targets created after this point.
42#
43
44add_library(rmm-common INTERFACE)
45
46target_compile_definitions(rmm-common
47    INTERFACE "$<$<CONFIG:Debug>:DEBUG>")
48
49if(MAX_CPUS EQUAL 0x0)
50    message(FATAL_ERROR "MAX_CPUS is not initialized")
51endif()
52
53target_compile_definitions(rmm-common
54    INTERFACE "MAX_CPUS=U(${MAX_CPUS})")
55
56if(NOT(GRANULE_SIZE EQUAL 4096))
57    message(FATAL_ERROR "GRANULE_SIZE is not initialized correctly")
58endif()
59
60target_compile_definitions(rmm-common
61    INTERFACE "GRANULE_SIZE=U(${GRANULE_SIZE})")
62
63if(RMM_FPU_USE_AT_REL2)
64    target_compile_definitions(rmm-common
65        INTERFACE "RMM_FPU_USE_AT_REL2=1")
66endif()
67
68#
69# Project name and version
70#
71target_compile_definitions(rmm-common
72    INTERFACE "NAME=\"${PROJECT_NAME}\"")
73
74target_compile_definitions(rmm-common
75    INTERFACE "VERSION=\"${PROJECT_VERSION}\"")
76
77#
78# Get git commit information
79#
80find_package(Git)
81if(GIT_FOUND)
82  execute_process(
83    COMMAND ${GIT_EXECUTABLE} describe --always --dirty --tags
84    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
85    OUTPUT_VARIABLE COMMIT_INFO
86    OUTPUT_STRIP_TRAILING_WHITESPACE
87  )
88endif()
89
90target_compile_definitions(rmm-common
91    INTERFACE "COMMIT_INFO=\"${COMMIT_INFO}\"")
92
93link_libraries(rmm-common)
94