mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
tf-psa-crypto: Add cmake_package test program
We cannot add the equivalent of cmake_package_install yet as the build in tf-psa-crypto still references some headers in ./include/mbedtls like mbedtls_config.h. We cannot add the equivalent of cmake_subproject yet as currently only the case of the Mbed TLS parent project is supported. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
@ -143,6 +143,27 @@ component_test_cmake_as_package () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component_test_tf_psa_crypto_cmake_as_package () {
|
||||||
|
# Remove existing generated files so that we use the ones CMake
|
||||||
|
# generates
|
||||||
|
make neat
|
||||||
|
|
||||||
|
msg "build: cmake 'as-package' build"
|
||||||
|
root_dir="$(pwd)"
|
||||||
|
cd tf-psa-crypto/programs/test/cmake_package
|
||||||
|
build_variant_dir="$(pwd)"
|
||||||
|
cmake .
|
||||||
|
make
|
||||||
|
./cmake_package
|
||||||
|
if [[ "$OSTYPE" == linux* ]]; then
|
||||||
|
PKG_CONFIG_PATH="${build_variant_dir}/tf-psa-crypto/pkgconfig" \
|
||||||
|
${root_dir}/tests/scripts/pkgconfig.sh \
|
||||||
|
tfpsacrypto
|
||||||
|
# This is the EXPECTED package name. Renaming it could break consumers
|
||||||
|
# of pkg-config, consider carefully.
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
support_test_cmake_as_package () {
|
support_test_cmake_as_package () {
|
||||||
support_test_cmake_out_of_source
|
support_test_cmake_out_of_source
|
||||||
}
|
}
|
||||||
|
3
tf-psa-crypto/programs/test/cmake_package/.gitignore
vendored
Normal file
3
tf-psa-crypto/programs/test/cmake_package/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Makefile
|
||||||
|
cmake_package
|
||||||
|
tf-psa-crypto
|
35
tf-psa-crypto/programs/test/cmake_package/CMakeLists.txt
Normal file
35
tf-psa-crypto/programs/test/cmake_package/CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Simulate configuring and building TF-PSA-Crypto as the user might do it.
|
||||||
|
# We'll skip installing it, and use the build directory directly instead.
|
||||||
|
#
|
||||||
|
|
||||||
|
set(TF-PSA-Crypto_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../..")
|
||||||
|
set(TF-PSA-Crypto_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/tf-psa-crypto")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
|
"-H${TF-PSA-Crypto_SOURCE_DIR}"
|
||||||
|
"-B${TF-PSA-Crypto_BINARY_DIR}"
|
||||||
|
"-DENABLE_PROGRAMS=NO"
|
||||||
|
"-DENABLE_TESTING=NO")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
|
--build "${TF-PSA-Crypto_BINARY_DIR}")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Locate the package.
|
||||||
|
#
|
||||||
|
|
||||||
|
set(TF-PSA-Crypto_DIR "${TF-PSA-Crypto_BINARY_DIR}/cmake")
|
||||||
|
find_package(TF-PSA-Crypto REQUIRED)
|
||||||
|
|
||||||
|
#
|
||||||
|
# At this point, the TF-PSA-Crypto targets should have been imported, and we
|
||||||
|
# can now link to them from our own program.
|
||||||
|
#
|
||||||
|
|
||||||
|
add_executable(cmake_package cmake_package.c)
|
||||||
|
target_link_libraries(cmake_package TF-PSA-Crypto::mbedcrypto)
|
19
tf-psa-crypto/programs/test/cmake_package/cmake_package.c
Normal file
19
tf-psa-crypto/programs/test/cmake_package/cmake_package.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Simple program to test that TF-PSA-Crypto builds correctly as a CMake
|
||||||
|
* package.
|
||||||
|
*
|
||||||
|
* Copyright The Mbed TLS Contributors
|
||||||
|
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <psa/crypto.h>
|
||||||
|
|
||||||
|
/* The main reason to build this is for testing the CMake build, so the program
|
||||||
|
* doesn't need to do very much. It calls a PSA cryptography API to ensure
|
||||||
|
* linkage works, but that is all. */
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
psa_crypto_init();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user