mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 04:15:34 +00:00
Merge remote-tracking branch 'origin/pr/2706' into development
* origin/pr/2706: Update Mbed Crypto to contain mbed-crypto#152 CMake: Add a subdirectory build regression test README: Enable builds as a CMake subproject ChangeLog: Enable builds as a CMake subproject Remove use of CMAKE_SOURCE_DIR
This commit is contained in:
commit
0b8b5e3393
|
@ -5,6 +5,8 @@ else()
|
||||||
project("mbed TLS" C)
|
project("mbed TLS" C)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(MBEDTLS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library." OFF)
|
option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library." OFF)
|
||||||
option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF)
|
option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF)
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,8 @@ Changes
|
||||||
* Add `reproducible` option to `ssl_client2` and `ssl_server2` to enable
|
* Add `reproducible` option to `ssl_client2` and `ssl_server2` to enable
|
||||||
test runs without variability. Contributed by Philippe Antoine (Catena
|
test runs without variability. Contributed by Philippe Antoine (Catena
|
||||||
cyber) in #2681.
|
cyber) in #2681.
|
||||||
|
* Enable building of Mbed TLS as a CMake subproject. Suggested and fixed by
|
||||||
|
Ashley Duncan in #2609.
|
||||||
|
|
||||||
= mbed TLS 2.17.0 branch released 2019-03-19
|
= mbed TLS 2.17.0 branch released 2019-03-19
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,12 @@ Regarding variables, also note that if you set CFLAGS when invoking cmake,
|
||||||
your value of CFLAGS doesn't override the content provided by cmake (depending
|
your value of CFLAGS doesn't override the content provided by cmake (depending
|
||||||
on the build mode as seen above), it's merely prepended to it.
|
on the build mode as seen above), it's merely prepended to it.
|
||||||
|
|
||||||
|
#### Mbed TLS as a subproject
|
||||||
|
|
||||||
|
Mbed TLS, like Mbed Crypto, supports being built as a CMake subproject. One can
|
||||||
|
use `add_subdirectory()` from a parent CMake project to include Mbed TLS as a
|
||||||
|
subproject.
|
||||||
|
|
||||||
### Microsoft Visual Studio
|
### Microsoft Visual Studio
|
||||||
|
|
||||||
The build files for Microsoft Visual Studio are generated for Visual Studio 2010.
|
The build files for Microsoft Visual Studio are generated for Visual Studio 2010.
|
||||||
|
|
|
@ -151,15 +151,15 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
|
||||||
set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
|
set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
|
||||||
target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target})
|
target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target})
|
||||||
target_include_directories(${mbedx509_static_target}
|
target_include_directories(${mbedx509_static_target}
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/include/
|
PUBLIC ${MBEDTLS_DIR}/include/
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/)
|
PUBLIC ${MBEDTLS_DIR}/crypto/include/)
|
||||||
|
|
||||||
add_library(${mbedtls_static_target} STATIC ${src_tls})
|
add_library(${mbedtls_static_target} STATIC ${src_tls})
|
||||||
set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
|
set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
|
||||||
target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target})
|
target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target})
|
||||||
target_include_directories(${mbedtls_static_target}
|
target_include_directories(${mbedtls_static_target}
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/include/
|
PUBLIC ${MBEDTLS_DIR}/include/
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/
|
PUBLIC ${MBEDTLS_DIR}/crypto/include/
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,15 +175,15 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
set_target_properties(mbedx509 PROPERTIES VERSION 2.17.0 SOVERSION 0)
|
set_target_properties(mbedx509 PROPERTIES VERSION 2.17.0 SOVERSION 0)
|
||||||
target_link_libraries(mbedx509 ${libs} mbedcrypto)
|
target_link_libraries(mbedx509 ${libs} mbedcrypto)
|
||||||
target_include_directories(mbedx509
|
target_include_directories(mbedx509
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/include/
|
PUBLIC ${MBEDTLS_DIR}/include/
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/)
|
PUBLIC ${MBEDTLS_DIR}/crypto/include/)
|
||||||
|
|
||||||
add_library(mbedtls SHARED ${src_tls})
|
add_library(mbedtls SHARED ${src_tls})
|
||||||
set_target_properties(mbedtls PROPERTIES VERSION 2.17.0 SOVERSION 12)
|
set_target_properties(mbedtls PROPERTIES VERSION 2.17.0 SOVERSION 12)
|
||||||
target_link_libraries(mbedtls ${libs} mbedx509)
|
target_link_libraries(mbedtls ${libs} mbedx509)
|
||||||
target_include_directories(mbedtls
|
target_include_directories(mbedtls
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/include/
|
PUBLIC ${MBEDTLS_DIR}/include/
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/)
|
PUBLIC ${MBEDTLS_DIR}/crypto/include/)
|
||||||
|
|
||||||
install(TARGETS mbedtls mbedx509
|
install(TARGETS mbedtls mbedx509
|
||||||
DESTINATION ${LIB_INSTALL_DIR}
|
DESTINATION ${LIB_INSTALL_DIR}
|
||||||
|
|
3
programs/test/cmake_subproject/.gitignore
vendored
Normal file
3
programs/test/cmake_subproject/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
build
|
||||||
|
Makefile
|
||||||
|
cmake_subproject
|
19
programs/test/cmake_subproject/CMakeLists.txt
Normal file
19
programs/test/cmake_subproject/CMakeLists.txt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
|
# We use the parent Mbed TLS directory as the MBEDTLS_DIR for this test. Other
|
||||||
|
# projects that use Mbed TLS as a subproject are likely to add by their own
|
||||||
|
# relative paths.
|
||||||
|
set(MBEDTLS_DIR ../../../)
|
||||||
|
|
||||||
|
# Add Mbed TLS as a subdirectory.
|
||||||
|
add_subdirectory(${MBEDTLS_DIR} build)
|
||||||
|
|
||||||
|
# Link against all the Mbed TLS libraries.
|
||||||
|
set(libs
|
||||||
|
mbedtls
|
||||||
|
mbedcrypto
|
||||||
|
mbedx509
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(cmake_subproject cmake_subproject.c)
|
||||||
|
target_link_libraries(cmake_subproject ${libs})
|
56
programs/test/cmake_subproject/cmake_subproject.c
Normal file
56
programs/test/cmake_subproject/cmake_subproject.c
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Simple program to test that CMake builds with Mbed TLS as a subdirectory
|
||||||
|
* work correctly.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2019, ARM Limited, All Rights Reserved
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||||
|
#include "mbedtls/config.h"
|
||||||
|
#else
|
||||||
|
#include MBEDTLS_CONFIG_FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_PLATFORM_C)
|
||||||
|
#include "mbedtls/platform.h"
|
||||||
|
#else
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define mbedtls_fprintf fprintf
|
||||||
|
#define mbedtls_printf printf
|
||||||
|
#define mbedtls_exit exit
|
||||||
|
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||||
|
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||||
|
#endif /* MBEDTLS_PLATFORM_C */
|
||||||
|
|
||||||
|
#include "mbedtls/version.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 single library function to ensure
|
||||||
|
* linkage works, but that is all. */
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
/* This version string is 18 bytes long, as advised by version.h. */
|
||||||
|
char version[18];
|
||||||
|
|
||||||
|
mbedtls_version_get_string_full( version );
|
||||||
|
|
||||||
|
mbedtls_printf( "Built against %s\n", version );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
|
@ -242,6 +242,11 @@ cleanup()
|
||||||
git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
|
git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
# Remove any artifacts from the component_test_cmake_as_subdirectory test.
|
||||||
|
rm -rf programs/test/cmake_subproject/build
|
||||||
|
rm -f programs/test/cmake_subproject/Makefile
|
||||||
|
rm -f programs/test/cmake_subproject/cmake_subproject
|
||||||
|
|
||||||
if [ -f "$CONFIG_BAK" ]; then
|
if [ -f "$CONFIG_BAK" ]; then
|
||||||
mv "$CONFIG_BAK" "$CONFIG_H"
|
mv "$CONFIG_BAK" "$CONFIG_H"
|
||||||
fi
|
fi
|
||||||
|
@ -1219,6 +1224,19 @@ component_test_cmake_out_of_source () {
|
||||||
unset MBEDTLS_ROOT_DIR
|
unset MBEDTLS_ROOT_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component_test_cmake_as_subdirectory () {
|
||||||
|
msg "build: cmake 'as-subdirectory' build"
|
||||||
|
MBEDTLS_ROOT_DIR="$PWD"
|
||||||
|
|
||||||
|
cd programs/test/cmake_subproject
|
||||||
|
cmake .
|
||||||
|
make
|
||||||
|
if_build_succeeded ./cmake_subproject
|
||||||
|
|
||||||
|
cd "$MBEDTLS_ROOT_DIR"
|
||||||
|
unset MBEDTLS_ROOT_DIR
|
||||||
|
}
|
||||||
|
|
||||||
component_test_zeroize () {
|
component_test_zeroize () {
|
||||||
# Test that the function mbedtls_platform_zeroize() is not optimized away by
|
# Test that the function mbedtls_platform_zeroize() is not optimized away by
|
||||||
# different combinations of compilers and optimization flags by using an
|
# different combinations of compilers and optimization flags by using an
|
||||||
|
|
Loading…
Reference in a new issue