| 1 | # |
| 2 | # SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 3 | # |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | |
| 7 | # ------------------------------------------------------------------------------------------------- |
| 8 | # cmake-format: off |
| 9 | |
| 10 | set(CMAKE_SYSTEM_NAME Generic) |
| 11 | set(CMAKE_SYSTEM_PROCESSOR arm) |
| 12 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) |
| 13 | |
| 14 | if(NOT DEFINED COMPILER_TRIPLET) |
| 15 | set(COMPILER_TRIPLET arm-none-eabi) |
| 16 | endif() |
| 17 | if(NOT DEFINED CMAKE_C_COMPILER) |
| 18 | set(CMAKE_C_COMPILER ${COMPILER_TRIPLET}-gcc) |
| 19 | endif() |
| 20 | if(NOT DEFINED CMAKE_CXX_COMPILER) |
| 21 | set(CMAKE_CXX_COMPILER ${COMPILER_TRIPLET}-g++) |
| 22 | endif() |
| 23 | |
| 24 | # Try to locate the specs file using the compiler |
| 25 | set(_KLEIDIAI_OPS_SPECS_NAME aprofile-validation.specs) |
| 26 | set(_KLEIDIAI_OPS_FULL_SPECS_PATH) |
| 27 | |
| 28 | execute_process( |
| 29 | COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=${_KLEIDIAI_OPS_SPECS_NAME} |
| 30 | OUTPUT_VARIABLE _KLEIDIAI_OPS_SPECS_SEARCH_OUTPUT |
| 31 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 32 | ERROR_QUIET |
| 33 | ) |
| 34 | |
| 35 | if(_KLEIDIAI_OPS_SPECS_SEARCH_OUTPUT AND (NOT _KLEIDIAI_OPS_SPECS_SEARCH_OUTPUT STREQUAL "${_KLEIDIAI_OPS_SPECS_NAME}") AND (EXISTS "${_KLEIDIAI_OPS_SPECS_SEARCH_OUTPUT}")) |
| 36 | set(_KLEIDIAI_OPS_FULL_SPECS_PATH "${_KLEIDIAI_OPS_SPECS_SEARCH_OUTPUT}") |
| 37 | else() |
| 38 | set(_KLEIDIAI_OPS_FULL_SPECS_PATH "${_KLEIDIAI_OPS_SPECS_NAME}") |
| 39 | message(WARNING "Could not resolve '${_KLEIDIAI_OPS_SPECS_NAME}' via -print-file-name.") |
| 40 | endif() |
| 41 | |
| 42 | set(KLEIDIAI_OPS_ENABLE_NATIVE OFF CACHE BOOL "Enable native build" FORCE) |
| 43 | set(KLEIDIAI_OPS_ENABLE_BARE_METAL ON CACHE BOOL "Enable bare-metal mode" FORCE) |
| 44 | set(KLEIDIAI_OPS_ENABLE_AARCH32 ON CACHE BOOL "Enable AArch32 mode" FORCE) |
| 45 | set(KLEIDIAI_OPS_ENABLE_ANDROID OFF CACHE BOOL "Enable Android build" FORCE) |
| 46 | |
| 47 | set(KLEIDIAI_OPS_CCXX_FLAGS_INIT -specs=${_KLEIDIAI_OPS_FULL_SPECS_PATH} -mfloat-abi=hard -mfpu=neon-fp16 -mfp16-format=ieee CACHE STRING "Base C/CXX flags.") |
| 48 | set(KLEIDIAI_OPS_CCXX_FLAGS_DEBUG "" CACHE STRING "Debug config specific C/CXX flags.") |
| 49 | set(KLEIDIAI_OPS_CCXX_FLAGS_RELEASE "" CACHE STRING "Release config specific C/CXX flags.") |
| 50 | |
| 51 | set(KLEIDIAI_OPS_LINKER_FLAGS_INIT -specs=${_KLEIDIAI_OPS_FULL_SPECS_PATH} -mfloat-abi=hard -mfpu=neon-fp16 CACHE STRING "Base linker flags.") |
| 52 | set(KLEIDIAI_OPS_LINKER_FLAGS_DEBUG "" CACHE STRING "Debug config specific linker flags.") |
| 53 | set(KLEIDIAI_OPS_LINKER_FLAGS_RELEASE "" CACHE STRING "Release config specific linker flags.") |
| 54 | |
| 55 | # cmake-format: on |
| 56 | # ------------------------------------------------------------------------------------------------- |