Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Balint Dobszay | 047aea8 | 2022-05-16 14:20:53 +0200 | [diff] [blame] | 2 | # Copyright (c) 2020-2022, 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 | |
Gyorgy Szing | b9596cd | 2022-03-03 01:10:23 +0100 | [diff] [blame] | 40 | # Include newlib into the build, but do no add SP executable specific files to libsp. |
| 41 | # Use a dummy target which will never be built. |
| 42 | add_library(dummy EXCLUDE_FROM_ALL) |
| 43 | add_components(TARGET dummy |
| 44 | BASE_DIR ${TS_ROOT} |
| 45 | COMPONENTS |
| 46 | environments/opteesp |
| 47 | ) |
| 48 | |
| 49 | # Get libc specific settings from newlib. |
| 50 | target_link_libraries(sp PRIVATE stdlib::c) |
| 51 | |
| 52 | target_compile_definitions(sp PRIVATE |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 53 | ARM64=1 |
| 54 | ) |
| 55 | |
| 56 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
Gyorgy Szing | b9596cd | 2022-03-03 01:10:23 +0100 | [diff] [blame] | 57 | target_compile_options(sp PRIVATE |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 58 | -fdiagnostics-show-option |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 59 | -gdwarf-2 |
| 60 | -mstrict-align |
| 61 | -O0 |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 62 | -std=c99 |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 63 | ) |
| 64 | endif() |
| 65 | |
| 66 | ######################################## install |
| 67 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 68 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 69 | endif() |
| 70 | |
| 71 | install( |
| 72 | TARGETS |
| 73 | sp |
| 74 | EXPORT |
| 75 | LibspTargets |
| 76 | ARCHIVE DESTINATION |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 77 | ${TS_ENV}/lib |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 78 | PUBLIC_HEADER DESTINATION |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 79 | ${TS_ENV}/include |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 80 | COMPONENT |
| 81 | libsp |
| 82 | ) |
| 83 | |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 84 | ### Create a config file package. |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 85 | set(ConfigPackageLocation ${TS_ENV}/lib/cmake/libsp) |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 86 | |
| 87 | include(CMakePackageConfigHelpers) |
| 88 | write_basic_package_version_file( |
| 89 | "${CMAKE_CURRENT_BINARY_DIR}/LibspConfigVersion.cmake" |
Gyorgy Szing | 0afc491 | 2022-07-20 06:26:25 +0000 | [diff] [blame^] | 90 | VERSION "${LIBSP_VERSION}" |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 91 | COMPATIBILITY SameMajorVersion |
| 92 | ) |
| 93 | |
| 94 | # Create targets file. |
| 95 | export( |
| 96 | EXPORT |
| 97 | LibspTargets |
| 98 | FILE |
| 99 | "${CMAKE_CURRENT_BINARY_DIR}/LibspTargets.cmake" |
| 100 | NAMESPACE |
| 101 | libsp:: |
| 102 | ) |
| 103 | |
| 104 | # Finalize config file. |
| 105 | configure_package_config_file( |
| 106 | LibspConfig.cmake.in |
| 107 | "${CMAKE_CURRENT_BINARY_DIR}/LibspConfig.cmake" |
| 108 | PATH_VARS |
| 109 | |
| 110 | INSTALL_DESTINATION |
| 111 | ${ConfigPackageLocation} |
| 112 | ) |
| 113 | |
| 114 | install( |
| 115 | EXPORT |
| 116 | LibspTargets |
| 117 | FILE |
| 118 | LibspTargets.cmake |
| 119 | NAMESPACE |
| 120 | libsp:: |
| 121 | DESTINATION |
| 122 | ${ConfigPackageLocation} |
| 123 | COMPONENT |
| 124 | libsp |
| 125 | ) |
| 126 | |
| 127 | # install config and version files |
| 128 | install( |
| 129 | FILES |
| 130 | "${CMAKE_CURRENT_BINARY_DIR}/LibspConfig.cmake" |
| 131 | "${CMAKE_CURRENT_BINARY_DIR}/LibspConfigVersion.cmake" |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 132 | DESTINATION |
| 133 | ${ConfigPackageLocation} |
| 134 | COMPONENT |
| 135 | libsp |
| 136 | ) |