Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Imre Kis | d47a145 | 2024-05-29 14:25:59 +0200 | [diff] [blame] | 2 | # Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved. |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
Balint Dobszay | 047aea8 | 2022-05-16 14:20:53 +0200 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.18 FATAL_ERROR) |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 8 | include(../../deployment.cmake REQUIRED) |
| 9 | |
| 10 | #------------------------------------------------------------------------------- |
| 11 | # The CMakeLists.txt for building the libsp deployment for opteesp |
| 12 | # |
Gyorgy Szing | b9596cd | 2022-03-03 01:10:23 +0100 | [diff] [blame] | 13 | # Used for building the libsp library that provides FFA related functions |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 14 | # for applications deployed in a secure partition. |
| 15 | #------------------------------------------------------------------------------- |
| 16 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
| 17 | |
Gyorgy Szing | 0afc491 | 2022-07-20 06:26:25 +0000 | [diff] [blame] | 18 | version_semver_read(FILE "${CMAKE_CURRENT_LIST_DIR}/version.txt" |
| 19 | MAJOR _major MINOR _minor PATCH _patch) |
| 20 | set(LIBSP_VERSION "${_major}.${_minor}.${_patch}") |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 21 | project(trusted-services |
| 22 | VERSION |
| 23 | ${LIBSP_VERSION} |
| 24 | LANGUAGES |
| 25 | C ASM |
| 26 | ) |
Gyorgy Szing | 0afc491 | 2022-07-20 06:26:25 +0000 | [diff] [blame] | 27 | unset(_major) |
| 28 | unset(_minor) |
| 29 | unset(_patch) |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 30 | |
| 31 | add_library(sp STATIC) |
| 32 | |
Gyorgy Szing | b9596cd | 2022-03-03 01:10:23 +0100 | [diff] [blame] | 33 | add_components(TARGET sp |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 34 | BASE_DIR ${TS_ROOT} |
| 35 | COMPONENTS |
| 36 | components/messaging/ffa/libsp |
| 37 | components/common/utils |
| 38 | ) |
| 39 | |
Imre Kis | d47a145 | 2024-05-29 14:25:59 +0200 | [diff] [blame] | 40 | add_subdirectory(${TS_ROOT}/components/common/libc ${CMAKE_BINARY_DIR}/libc_build) |
Gyorgy Szing | b9596cd | 2022-03-03 01:10:23 +0100 | [diff] [blame] | 41 | |
| 42 | target_compile_definitions(sp PRIVATE |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 43 | ARM64=1 |
| 44 | ) |
| 45 | |
| 46 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
Gyorgy Szing | b9596cd | 2022-03-03 01:10:23 +0100 | [diff] [blame] | 47 | target_compile_options(sp PRIVATE |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 48 | -std=c99 |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 49 | ) |
| 50 | endif() |
| 51 | |
| 52 | ######################################## install |
| 53 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 54 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 55 | endif() |
| 56 | |
| 57 | install( |
| 58 | TARGETS |
| 59 | sp |
| 60 | EXPORT |
| 61 | LibspTargets |
| 62 | ARCHIVE DESTINATION |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 63 | ${TS_ENV}/lib |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 64 | PUBLIC_HEADER DESTINATION |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 65 | ${TS_ENV}/include |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 66 | COMPONENT |
| 67 | libsp |
| 68 | ) |
| 69 | |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 70 | ### Create a config file package. |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 71 | set(ConfigPackageLocation ${TS_ENV}/lib/cmake/libsp) |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 72 | |
| 73 | include(CMakePackageConfigHelpers) |
| 74 | write_basic_package_version_file( |
| 75 | "${CMAKE_CURRENT_BINARY_DIR}/LibspConfigVersion.cmake" |
Gyorgy Szing | 0afc491 | 2022-07-20 06:26:25 +0000 | [diff] [blame] | 76 | VERSION "${LIBSP_VERSION}" |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 77 | COMPATIBILITY SameMajorVersion |
| 78 | ) |
| 79 | |
| 80 | # Create targets file. |
| 81 | export( |
| 82 | EXPORT |
| 83 | LibspTargets |
| 84 | FILE |
| 85 | "${CMAKE_CURRENT_BINARY_DIR}/LibspTargets.cmake" |
| 86 | NAMESPACE |
| 87 | libsp:: |
| 88 | ) |
| 89 | |
| 90 | # Finalize config file. |
| 91 | configure_package_config_file( |
| 92 | LibspConfig.cmake.in |
| 93 | "${CMAKE_CURRENT_BINARY_DIR}/LibspConfig.cmake" |
| 94 | PATH_VARS |
| 95 | |
| 96 | INSTALL_DESTINATION |
| 97 | ${ConfigPackageLocation} |
| 98 | ) |
| 99 | |
| 100 | install( |
| 101 | EXPORT |
| 102 | LibspTargets |
| 103 | FILE |
| 104 | LibspTargets.cmake |
| 105 | NAMESPACE |
| 106 | libsp:: |
| 107 | DESTINATION |
| 108 | ${ConfigPackageLocation} |
| 109 | COMPONENT |
| 110 | libsp |
| 111 | ) |
| 112 | |
| 113 | # install config and version files |
| 114 | install( |
| 115 | FILES |
| 116 | "${CMAKE_CURRENT_BINARY_DIR}/LibspConfig.cmake" |
| 117 | "${CMAKE_CURRENT_BINARY_DIR}/LibspConfigVersion.cmake" |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 118 | DESTINATION |
| 119 | ${ConfigPackageLocation} |
| 120 | COMPONENT |
| 121 | libsp |
| 122 | ) |