mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Add CMake package config file
This change enables automatic detection and consumption of Mbed TLS library targets from within other CMake projects. By generating an `MbedTLSConfig.cmake` file, consuming projects receive a more complete view of these targets, allowing them to be used as dependencies which properly inherit the transitive dependencies of the libraries. This is fairly fragile, as it seems Mbed TLS's libraries do not appear to properly model their dependencies on other targets, including third-party dependencies. It is, however, sufficient for building and linking the compiled Mbed TLS libraries when there are no third-party dependencies involved. Further work is needed for more complex use-cases, but this will likely meet the needs of most projects. Resolves #298. Probably useful for #2857. Signed-off-by: Chris Kay <chris.kay@arm.com>
This commit is contained in:
@ -273,7 +273,7 @@ cleanup()
|
||||
-iname CMakeFiles -exec rm -rf {} \+ -o \
|
||||
\( -iname cmake_install.cmake -o \
|
||||
-iname CTestTestfile.cmake -o \
|
||||
-iname CMakeCache.txt \) -exec rm {} \+
|
||||
-iname CMakeCache.txt \) -exec rm -f {} \+
|
||||
# Recover files overwritten by in-tree CMake builds
|
||||
rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
|
||||
git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
|
||||
@ -284,6 +284,16 @@ cleanup()
|
||||
rm -f programs/test/cmake_subproject/Makefile
|
||||
rm -f programs/test/cmake_subproject/cmake_subproject
|
||||
|
||||
# Remove any artifacts from the component_test_cmake_as_package test.
|
||||
rm -rf programs/test/cmake_package/build
|
||||
rm -f programs/test/cmake_package/Makefile
|
||||
rm -f programs/test/cmake_package/cmake_package
|
||||
|
||||
# Remove any artifacts from the component_test_cmake_as_installed_package test.
|
||||
rm -rf programs/test/cmake_package_install/build
|
||||
rm -f programs/test/cmake_package_install/Makefile
|
||||
rm -f programs/test/cmake_package_install/cmake_package_install
|
||||
|
||||
if [ -f "$CONFIG_BAK" ]; then
|
||||
mv "$CONFIG_BAK" "$CONFIG_H"
|
||||
fi
|
||||
@ -2609,6 +2619,32 @@ component_test_cmake_as_subdirectory () {
|
||||
unset MBEDTLS_ROOT_DIR
|
||||
}
|
||||
|
||||
component_test_cmake_as_package () {
|
||||
msg "build: cmake 'as-package' build"
|
||||
MBEDTLS_ROOT_DIR="$PWD"
|
||||
|
||||
cd programs/test/cmake_package
|
||||
cmake .
|
||||
make
|
||||
if_build_succeeded ./cmake_package
|
||||
|
||||
cd "$MBEDTLS_ROOT_DIR"
|
||||
unset MBEDTLS_ROOT_DIR
|
||||
}
|
||||
|
||||
component_test_cmake_as_package_install () {
|
||||
msg "build: cmake 'as-installed-package' build"
|
||||
MBEDTLS_ROOT_DIR="$PWD"
|
||||
|
||||
cd programs/test/cmake_package_install
|
||||
cmake .
|
||||
make
|
||||
if_build_succeeded ./cmake_package_install
|
||||
|
||||
cd "$MBEDTLS_ROOT_DIR"
|
||||
unset MBEDTLS_ROOT_DIR
|
||||
}
|
||||
|
||||
component_test_zeroize () {
|
||||
# Test that the function mbedtls_platform_zeroize() is not optimized away by
|
||||
# different combinations of compilers and optimization flags by using an
|
||||
|
Reference in New Issue
Block a user