blob: efbcda7d1fa95d6bff6bf41fe40830e9aca11a1a [file] [log] [blame]
Gyorgy Szing49091802020-11-24 00:33:09 +01001#-------------------------------------------------------------------------------
Imre Kisd47a1452024-05-29 14:25:59 +02002# Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved.
Gyorgy Szing49091802020-11-24 00:33:09 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
Balint Dobszay047aea82022-05-16 14:20:53 +02007cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
Gyorgy Szing49091802020-11-24 00:33:09 +01008include(../../deployment.cmake REQUIRED)
9
10#-------------------------------------------------------------------------------
11# The CMakeLists.txt for building the libsp deployment for opteesp
12#
Gyorgy Szingb9596cd2022-03-03 01:10:23 +010013# Used for building the libsp library that provides FFA related functions
Gyorgy Szing49091802020-11-24 00:33:09 +010014# for applications deployed in a secure partition.
15#-------------------------------------------------------------------------------
16include(${TS_ROOT}/environments/opteesp/env.cmake)
17
Gyorgy Szing0afc4912022-07-20 06:26:25 +000018version_semver_read(FILE "${CMAKE_CURRENT_LIST_DIR}/version.txt"
19 MAJOR _major MINOR _minor PATCH _patch)
20set(LIBSP_VERSION "${_major}.${_minor}.${_patch}")
Gyorgy Szing49091802020-11-24 00:33:09 +010021project(trusted-services
22 VERSION
23 ${LIBSP_VERSION}
24 LANGUAGES
25 C ASM
26 )
Gyorgy Szing0afc4912022-07-20 06:26:25 +000027unset(_major)
28unset(_minor)
29unset(_patch)
Gyorgy Szing49091802020-11-24 00:33:09 +010030
31add_library(sp STATIC)
32
Gyorgy Szingb9596cd2022-03-03 01:10:23 +010033add_components(TARGET sp
Gyorgy Szing49091802020-11-24 00:33:09 +010034 BASE_DIR ${TS_ROOT}
35 COMPONENTS
36 components/messaging/ffa/libsp
37 components/common/utils
38)
39
Imre Kisd47a1452024-05-29 14:25:59 +020040add_subdirectory(${TS_ROOT}/components/common/libc ${CMAKE_BINARY_DIR}/libc_build)
Gyorgy Szingb9596cd2022-03-03 01:10:23 +010041
42target_compile_definitions(sp PRIVATE
Gyorgy Szing49091802020-11-24 00:33:09 +010043 ARM64=1
44)
45
46if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
Gyorgy Szingb9596cd2022-03-03 01:10:23 +010047 target_compile_options(sp PRIVATE
Andrew Beggs97a00d42021-06-15 15:45:46 +000048 -std=c99
Gyorgy Szing49091802020-11-24 00:33:09 +010049 )
50endif()
51
52######################################## install
53if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
54 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
55endif()
56
57install(
58 TARGETS
59 sp
60 EXPORT
61 LibspTargets
62 ARCHIVE DESTINATION
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010063 ${TS_ENV}/lib
Gyorgy Szing49091802020-11-24 00:33:09 +010064 PUBLIC_HEADER DESTINATION
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010065 ${TS_ENV}/include
Gyorgy Szing49091802020-11-24 00:33:09 +010066 COMPONENT
67 libsp
68)
69
Gyorgy Szing49091802020-11-24 00:33:09 +010070### Create a config file package.
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010071set(ConfigPackageLocation ${TS_ENV}/lib/cmake/libsp)
Gyorgy Szing49091802020-11-24 00:33:09 +010072
73include(CMakePackageConfigHelpers)
74write_basic_package_version_file(
75 "${CMAKE_CURRENT_BINARY_DIR}/LibspConfigVersion.cmake"
Gyorgy Szing0afc4912022-07-20 06:26:25 +000076 VERSION "${LIBSP_VERSION}"
Gyorgy Szing49091802020-11-24 00:33:09 +010077 COMPATIBILITY SameMajorVersion
78)
79
80# Create targets file.
81export(
82 EXPORT
83 LibspTargets
84 FILE
85 "${CMAKE_CURRENT_BINARY_DIR}/LibspTargets.cmake"
86 NAMESPACE
87 libsp::
88)
89
90# Finalize config file.
91configure_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
100install(
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
114install(
115 FILES
116 "${CMAKE_CURRENT_BINARY_DIR}/LibspConfig.cmake"
117 "${CMAKE_CURRENT_BINARY_DIR}/LibspConfigVersion.cmake"
Gyorgy Szing49091802020-11-24 00:33:09 +0100118 DESTINATION
119 ${ConfigPackageLocation}
120 COMPONENT
121 libsp
122)