blob: 1fc2c4d607a3a3897a1db283e8c3d0f005db5070 [file] [log] [blame]
Gyorgy Szing49091802020-11-24 00:33:09 +01001#-------------------------------------------------------------------------------
Balint Dobszay047aea82022-05-16 14:20:53 +02002# Copyright (c) 2020-2022, 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
Gyorgy Szingb9596cd2022-03-03 01:10:23 +010040# 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.
42add_library(dummy EXCLUDE_FROM_ALL)
43add_components(TARGET dummy
44 BASE_DIR ${TS_ROOT}
45 COMPONENTS
46 environments/opteesp
47)
48
49# Get libc specific settings from newlib.
50target_link_libraries(sp PRIVATE stdlib::c)
51
52target_compile_definitions(sp PRIVATE
Gyorgy Szing49091802020-11-24 00:33:09 +010053 ARM64=1
54)
55
56if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
Gyorgy Szingb9596cd2022-03-03 01:10:23 +010057 target_compile_options(sp PRIVATE
Gyorgy Szing49091802020-11-24 00:33:09 +010058 -fdiagnostics-show-option
Gyorgy Szing49091802020-11-24 00:33:09 +010059 -gdwarf-2
60 -mstrict-align
61 -O0
Andrew Beggs97a00d42021-06-15 15:45:46 +000062 -std=c99
Gyorgy Szing49091802020-11-24 00:33:09 +010063 )
64endif()
65
66######################################## install
67if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
68 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
69endif()
70
71install(
72 TARGETS
73 sp
74 EXPORT
75 LibspTargets
76 ARCHIVE DESTINATION
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010077 ${TS_ENV}/lib
Gyorgy Szing49091802020-11-24 00:33:09 +010078 PUBLIC_HEADER DESTINATION
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010079 ${TS_ENV}/include
Gyorgy Szing49091802020-11-24 00:33:09 +010080 COMPONENT
81 libsp
82)
83
Gyorgy Szing49091802020-11-24 00:33:09 +010084### Create a config file package.
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010085set(ConfigPackageLocation ${TS_ENV}/lib/cmake/libsp)
Gyorgy Szing49091802020-11-24 00:33:09 +010086
87include(CMakePackageConfigHelpers)
88write_basic_package_version_file(
89 "${CMAKE_CURRENT_BINARY_DIR}/LibspConfigVersion.cmake"
Gyorgy Szing0afc4912022-07-20 06:26:25 +000090 VERSION "${LIBSP_VERSION}"
Gyorgy Szing49091802020-11-24 00:33:09 +010091 COMPATIBILITY SameMajorVersion
92)
93
94# Create targets file.
95export(
96 EXPORT
97 LibspTargets
98 FILE
99 "${CMAKE_CURRENT_BINARY_DIR}/LibspTargets.cmake"
100 NAMESPACE
101 libsp::
102)
103
104# Finalize config file.
105configure_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
114install(
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
128install(
129 FILES
130 "${CMAKE_CURRENT_BINARY_DIR}/LibspConfig.cmake"
131 "${CMAKE_CURRENT_BINARY_DIR}/LibspConfigVersion.cmake"
Gyorgy Szing49091802020-11-24 00:33:09 +0100132 DESTINATION
133 ${ConfigPackageLocation}
134 COMPONENT
135 libsp
136)