Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame^] | 1 | # |
| 2 | # SPDX-License-Identifier: BSD-3-Clause |
| 3 | # SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 4 | # |
| 5 | |
| 6 | # |
| 7 | # Common config options |
| 8 | # |
| 9 | arm_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 | # |
| 18 | arm_config_option( |
| 19 | NAME GRANULE_SIZE |
| 20 | HELP "Granule Size used by RMM" |
| 21 | TYPE STRING |
| 22 | DEFAULT 4096) |
| 23 | |
| 24 | arm_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. |
| 31 | arm_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 | |
| 44 | add_library(rmm-common INTERFACE) |
| 45 | |
| 46 | target_compile_definitions(rmm-common |
| 47 | INTERFACE "$<$<CONFIG:Debug>:DEBUG>") |
| 48 | |
| 49 | if(MAX_CPUS EQUAL 0x0) |
| 50 | message(FATAL_ERROR "MAX_CPUS is not initialized") |
| 51 | endif() |
| 52 | |
| 53 | target_compile_definitions(rmm-common |
| 54 | INTERFACE "MAX_CPUS=U(${MAX_CPUS})") |
| 55 | |
| 56 | if(NOT(GRANULE_SIZE EQUAL 4096)) |
| 57 | message(FATAL_ERROR "GRANULE_SIZE is not initialized correctly") |
| 58 | endif() |
| 59 | |
| 60 | target_compile_definitions(rmm-common |
| 61 | INTERFACE "GRANULE_SIZE=U(${GRANULE_SIZE})") |
| 62 | |
| 63 | if(RMM_FPU_USE_AT_REL2) |
| 64 | target_compile_definitions(rmm-common |
| 65 | INTERFACE "RMM_FPU_USE_AT_REL2=1") |
| 66 | endif() |
| 67 | |
| 68 | # |
| 69 | # Project name and version |
| 70 | # |
| 71 | target_compile_definitions(rmm-common |
| 72 | INTERFACE "NAME=\"${PROJECT_NAME}\"") |
| 73 | |
| 74 | target_compile_definitions(rmm-common |
| 75 | INTERFACE "VERSION=\"${PROJECT_VERSION}\"") |
| 76 | |
| 77 | # |
| 78 | # Get git commit information |
| 79 | # |
| 80 | find_package(Git) |
| 81 | if(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 | ) |
| 88 | endif() |
| 89 | |
| 90 | target_compile_definitions(rmm-common |
| 91 | INTERFACE "COMMIT_INFO=\"${COMMIT_INFO}\"") |
| 92 | |
| 93 | link_libraries(rmm-common) |