mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-24 06:02:44 +00:00
tf-psa-crypto: cmake: Add package config and install support
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
2d453c9b07
commit
f85882de57
@ -1,3 +1,4 @@
|
|||||||
|
include(CMakePackageConfigHelpers)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# Determine if TF-PSA-Crypto is being built as a subproject using add_subdirectory()
|
# Determine if TF-PSA-Crypto is being built as a subproject using add_subdirectory()
|
||||||
@ -40,7 +41,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Support for package config and install to be added later.
|
# Support for package config and install to be added later.
|
||||||
option(DISABLE_PACKAGE_CONFIG_AND_INSTALL "Disable package configuration, target export and installation" ON)
|
option(DISABLE_PACKAGE_CONFIG_AND_INSTALL "Disable package configuration, target export and installation" ${TF_PSA_CRYPTO_AS_SUBPROJECT})
|
||||||
|
|
||||||
if (CMAKE_C_SIMULATE_ID)
|
if (CMAKE_C_SIMULATE_ID)
|
||||||
set(COMPILER_ID ${CMAKE_C_SIMULATE_ID})
|
set(COMPILER_ID ${CMAKE_C_SIMULATE_ID})
|
||||||
@ -281,6 +282,7 @@ endif()
|
|||||||
add_subdirectory(include)
|
add_subdirectory(include)
|
||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
add_subdirectory(drivers)
|
add_subdirectory(drivers)
|
||||||
|
add_subdirectory(pkgconfig)
|
||||||
|
|
||||||
#
|
#
|
||||||
# The C files in tests/src directory contain test code shared among test suites
|
# The C files in tests/src directory contain test code shared among test suites
|
||||||
@ -383,3 +385,39 @@ if(ENABLE_TESTING)
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl COPYONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl COPYONLY)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT DISABLE_PACKAGE_CONFIG_AND_INSTALL)
|
||||||
|
configure_package_config_file(
|
||||||
|
"cmake/TF-PSA-CryptoConfig.cmake.in"
|
||||||
|
"cmake/TF-PSA-CryptoConfig.cmake"
|
||||||
|
INSTALL_DESTINATION "cmake")
|
||||||
|
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"cmake/TF-PSA-CryptoConfigVersion.cmake"
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
VERSION 0.1.0)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/TF-PSA-CryptoConfig.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/TF-PSA-CryptoConfigVersion.cmake"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/TF-PSA-Crypto")
|
||||||
|
|
||||||
|
export(
|
||||||
|
EXPORT MbedTLSTargets
|
||||||
|
NAMESPACE TF-PSA-Crypto::
|
||||||
|
FILE "cmake/TF-PSA-CryptoTargets.cmake")
|
||||||
|
|
||||||
|
install(
|
||||||
|
EXPORT MbedTLSTargets
|
||||||
|
NAMESPACE TF-PSA-Crypto::
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/TF-PSA-Crypto"
|
||||||
|
FILE "TF-PSA-CryptoTargets.cmake")
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15)
|
||||||
|
# Do not export the package by default
|
||||||
|
cmake_policy(SET CMP0090 NEW)
|
||||||
|
|
||||||
|
# Make this package visible to the system
|
||||||
|
export(PACKAGE TF-PSA-Crypto)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
1
tf-psa-crypto/cmake/.gitignore
vendored
Normal file
1
tf-psa-crypto/cmake/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
TF-PSA-CryptoConfig.cmake
|
3
tf-psa-crypto/cmake/TF-PSA-CryptoConfig.cmake.in
Normal file
3
tf-psa-crypto/cmake/TF-PSA-CryptoConfig.cmake.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/TF-PSA-CryptoTargets.cmake")
|
2
tf-psa-crypto/pkgconfig/.gitignore
vendored
Normal file
2
tf-psa-crypto/pkgconfig/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Makefile
|
||||||
|
*.pc
|
15
tf-psa-crypto/pkgconfig/CMakeLists.txt
Normal file
15
tf-psa-crypto/pkgconfig/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
if(NOT DISABLE_PACKAGE_CONFIG_AND_INSTALL)
|
||||||
|
include(JoinPaths.cmake)
|
||||||
|
join_paths(PKGCONFIG_INCLUDEDIR "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
join_paths(PKGCONFIG_LIBDIR "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
|
||||||
|
#define these manually since minimum CMAKE version is not 3.9 for DESCRIPTION and 3.12 for HOMEPAGE_URL usage in project() below.
|
||||||
|
# Prefix with something that won't clash with newer versions of CMAKE.
|
||||||
|
set(PKGCONFIG_PROJECT_DESCRIPTION "TF-PSA-Crypto is a C library that implements cryptographic primitives. Its small code footprint makes it suitable for embedded systems.")
|
||||||
|
set(PKGCONFIG_PROJECT_HOMEPAGE_URL "https://www.trustedfirmware.org/projects/mbed-tls/")
|
||||||
|
|
||||||
|
configure_file(tfpsacrypto.pc.in tfpsacrypto.pc @ONLY)
|
||||||
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/tfpsacrypto.pc
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
|
endif()
|
27
tf-psa-crypto/pkgconfig/JoinPaths.cmake
Normal file
27
tf-psa-crypto/pkgconfig/JoinPaths.cmake
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||||
|
# This module provides function for joining paths
|
||||||
|
# known from most languages
|
||||||
|
#
|
||||||
|
# Copyright The Mbed TLS Contributors
|
||||||
|
#
|
||||||
|
# This script originates from:
|
||||||
|
# - https://github.com/jtojnar/cmake-snips
|
||||||
|
# Jan has provided re-licensing under Apache 2.0 and GPL 2.0+ and
|
||||||
|
# allowed for the change of Copyright.
|
||||||
|
#
|
||||||
|
# Modelled after Python’s os.path.join
|
||||||
|
# https://docs.python.org/3.7/library/os.path.html#os.path.join
|
||||||
|
# Windows not supported
|
||||||
|
function(join_paths joined_path first_path_segment)
|
||||||
|
set(temp_path "${first_path_segment}")
|
||||||
|
foreach(current_segment IN LISTS ARGN)
|
||||||
|
if(NOT ("${current_segment}" STREQUAL ""))
|
||||||
|
if(IS_ABSOLUTE "${current_segment}")
|
||||||
|
set(temp_path "${current_segment}")
|
||||||
|
else()
|
||||||
|
set(temp_path "${temp_path}/${current_segment}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(${joined_path} "${temp_path}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
10
tf-psa-crypto/pkgconfig/tfpsacrypto.pc.in
Normal file
10
tf-psa-crypto/pkgconfig/tfpsacrypto.pc.in
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
|
includedir=@PKGCONFIG_INCLUDEDIR@
|
||||||
|
libdir=@PKGCONFIG_LIBDIR@
|
||||||
|
|
||||||
|
Name: @PROJECT_NAME@
|
||||||
|
Description: @PKGCONFIG_PROJECT_DESCRIPTION@
|
||||||
|
URL: @PKGCONFIG_PROJECT_HOMEPAGE_URL@
|
||||||
|
Version: @PROJECT_VERSION@
|
||||||
|
Cflags: -I"${includedir}"
|
||||||
|
Libs: -L"${libdir}" -lmbedcrypto -lbuiltin -leverest -lp256m
|
Loading…
x
Reference in New Issue
Block a user