mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-09-13 14:22:19 +08:00
CMake: support custom base configurations
Signed-off-by: Yi Wu <yi.wu2@arm.com>
This commit is contained in:
parent
bf92cc769c
commit
346ece94cc
@ -139,22 +139,33 @@ set(MBEDTLS_CONFIG_SET "" CACHE STRING "Options to set, separated by semicolons
|
|||||||
set(MBEDTLS_CONFIG_UNSET "" CACHE STRING "Options to unset, separated by semicolons.")
|
set(MBEDTLS_CONFIG_UNSET "" CACHE STRING "Options to unset, separated by semicolons.")
|
||||||
|
|
||||||
if(MBEDTLS_CONFIG_NAME OR MBEDTLS_CONFIG_SET OR MBEDTLS_CONFIG_UNSET)
|
if(MBEDTLS_CONFIG_NAME OR MBEDTLS_CONFIG_SET OR MBEDTLS_CONFIG_UNSET)
|
||||||
if(MBEDTLS_CONFIG_FILE)
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"MBEDTLS_CONFIG_FILE cannot be combined with MBEDTLS_CONFIG_NAME, "
|
|
||||||
"MBEDTLS_CONFIG_SET or MBEDTLS_CONFIG_UNSET.")
|
|
||||||
endif()
|
|
||||||
if(NOT MBEDTLS_PYTHON_EXECUTABLE)
|
if(NOT MBEDTLS_PYTHON_EXECUTABLE)
|
||||||
message(FATAL_ERROR "Python 3 is required to generate an Mbed TLS configuration file.")
|
message(FATAL_ERROR "Python 3 is required to generate an Mbed TLS configuration file.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MBEDTLS_CONFIG_FILE)
|
||||||
|
set(MBEDTLS_BASE_CONFIG_FILE "${MBEDTLS_CONFIG_FILE}")
|
||||||
|
if(NOT EXISTS "${MBEDTLS_BASE_CONFIG_FILE}")
|
||||||
|
file(RELATIVE_PATH MBEDTLS_CONFIG_FILE_RELATIVE
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}" "${MBEDTLS_CONFIG_FILE}")
|
||||||
|
set(MBEDTLS_BASE_CONFIG_FILE
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${MBEDTLS_CONFIG_FILE_RELATIVE}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(MBEDTLS_BASE_CONFIG_FILE
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/mbedtls/mbedtls_config.h")
|
||||||
|
endif()
|
||||||
|
if(NOT EXISTS "${MBEDTLS_BASE_CONFIG_FILE}")
|
||||||
|
message(FATAL_ERROR "Mbed TLS configuration file not found: ${MBEDTLS_BASE_CONFIG_FILE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(MBEDTLS_GENERATED_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/include")
|
set(MBEDTLS_GENERATED_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/include")
|
||||||
set(MBEDTLS_GENERATED_CONFIG_FILE "${MBEDTLS_GENERATED_CONFIG_DIR}/mbedtls/mbedtls_config.h")
|
set(MBEDTLS_GENERATED_CONFIG_FILE "${MBEDTLS_GENERATED_CONFIG_DIR}/mbedtls/mbedtls_config.h")
|
||||||
set(MBEDTLS_GENERATED_CRYPTO_CONFIG_FILE "${MBEDTLS_GENERATED_CONFIG_DIR}/psa/crypto_config.h")
|
set(MBEDTLS_GENERATED_CRYPTO_CONFIG_FILE "${MBEDTLS_GENERATED_CONFIG_DIR}/psa/crypto_config.h")
|
||||||
file(MAKE_DIRECTORY "${MBEDTLS_GENERATED_CONFIG_DIR}/mbedtls")
|
file(MAKE_DIRECTORY "${MBEDTLS_GENERATED_CONFIG_DIR}/mbedtls")
|
||||||
file(MAKE_DIRECTORY "${MBEDTLS_GENERATED_CONFIG_DIR}/psa")
|
file(MAKE_DIRECTORY "${MBEDTLS_GENERATED_CONFIG_DIR}/psa")
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/include/mbedtls/mbedtls_config.h"
|
configure_file("${MBEDTLS_BASE_CONFIG_FILE}"
|
||||||
DESTINATION "${MBEDTLS_GENERATED_CONFIG_DIR}/mbedtls")
|
"${MBEDTLS_GENERATED_CONFIG_FILE}" COPYONLY)
|
||||||
# config.py handles the Mbed TLS and PSA configurations together. Give it
|
# config.py handles the Mbed TLS and PSA configurations together. Give it
|
||||||
# a build-tree PSA configuration so that it never modifies the source tree.
|
# a build-tree PSA configuration so that it never modifies the source tree.
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/include/psa/crypto_config.h"
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/include/psa/crypto_config.h"
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
Features
|
Features
|
||||||
* Add the `MBEDTLS_CONFIG_NAME`, `MBEDTLS_CONFIG_SET` and
|
* Add the `MBEDTLS_CONFIG_NAME`, `MBEDTLS_CONFIG_SET` and
|
||||||
`MBEDTLS_CONFIG_UNSET` CMake options for selecting and customizing
|
`MBEDTLS_CONFIG_UNSET` CMake options for selecting and customizing
|
||||||
compile-time configurations. Fixes #10838.
|
compile-time configurations, including configurations based on a custom
|
||||||
|
`MBEDTLS_CONFIG_FILE`. Fixes #10838.
|
||||||
|
|||||||
@ -299,15 +299,18 @@ component_build_cmake_config_options () {
|
|||||||
mkdir "$OUT_OF_SOURCE_DIR"
|
mkdir "$OUT_OF_SOURCE_DIR"
|
||||||
cd "$OUT_OF_SOURCE_DIR"
|
cd "$OUT_OF_SOURCE_DIR"
|
||||||
|
|
||||||
msg "build: cmake with MBEDTLS_CONFIG_SET and MBEDTLS_CONFIG_UNSET"
|
msg "build: cmake with a base config, MBEDTLS_CONFIG_SET and MBEDTLS_CONFIG_UNSET"
|
||||||
cmake '-DMBEDTLS_CONFIG_UNSET=MBEDTLS_SSL_ALL_ALERT_MESSAGES;MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE' \
|
cmake -DMBEDTLS_CONFIG_FILE=configs/config-ccm-psk-tls1_2.h \
|
||||||
'-DMBEDTLS_CONFIG_SET=MBEDTLS_SSL_PROTO_TLS1_3;MBEDTLS_SSL_ALL_ALERT_MESSAGES;MBEDTLS_SSL_IN_CONTENT_LEN=12000' \
|
-DMBEDTLS_CONFIG_UNSET=MBEDTLS_SSL_SRV_C \
|
||||||
|
'-DMBEDTLS_CONFIG_SET=MBEDTLS_SSL_RENEGOTIATION;MBEDTLS_DEBUG_C;MBEDTLS_ERROR_C;MBEDTLS_SSL_IN_CONTENT_LEN=12000' \
|
||||||
"$MBEDTLS_ROOT_DIR"
|
"$MBEDTLS_ROOT_DIR"
|
||||||
make query_compile_time_config
|
make query_compile_time_config
|
||||||
|
|
||||||
programs/test/query_compile_time_config MBEDTLS_SSL_PROTO_TLS1_3
|
programs/test/query_compile_time_config MBEDTLS_SSL_PROTO_TLS1_2
|
||||||
programs/test/query_compile_time_config MBEDTLS_SSL_ALL_ALERT_MESSAGES
|
programs/test/query_compile_time_config MBEDTLS_SSL_RENEGOTIATION
|
||||||
not programs/test/query_compile_time_config MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE
|
programs/test/query_compile_time_config MBEDTLS_DEBUG_C
|
||||||
|
programs/test/query_compile_time_config MBEDTLS_ERROR_C
|
||||||
|
not programs/test/query_compile_time_config MBEDTLS_SSL_SRV_C
|
||||||
[ "$(programs/test/query_compile_time_config MBEDTLS_SSL_IN_CONTENT_LEN)" = \
|
[ "$(programs/test/query_compile_time_config MBEDTLS_SSL_IN_CONTENT_LEN)" = \
|
||||||
"12000" ]
|
"12000" ]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user