Fix suppress_mbedtls_warnings

It seems everything needs "no-cast-qual" due to
mbedtls_get_unaligned_uint64.

Move the source file lists into functions so they can be used in
suppress_mbedtls_warnings to add -Wno-cast-qual to just mbedtls source
files.
This commit is contained in:
Peter Harper 2025-04-09 16:57:37 +01:00
parent 4bc43f3a47
commit 9c265bc149

View File

@ -28,143 +28,156 @@ if (EXISTS ${PICO_MBEDTLS_PATH}/${MBEDTLS_TEST_PATH})
pico_register_common_scope_var(MBEDTLS_VERSION_MAJOR)
endif()
set(src_crypto
aes.c
aesni.c
aria.c
asn1parse.c
asn1write.c
base64.c
bignum.c
camellia.c
ccm.c
chacha20.c
chachapoly.c
cipher.c
cipher_wrap.c
constant_time.c
cmac.c
ctr_drbg.c
des.c
dhm.c
ecdh.c
ecdsa.c
ecjpake.c
ecp.c
ecp_curves.c
entropy.c
entropy_poll.c
error.c
gcm.c
hkdf.c
hmac_drbg.c
md.c
md5.c
memory_buffer_alloc.c
mps_reader.c
mps_trace.c
nist_kw.c
oid.c
padlock.c
pem.c
pk.c
pk_wrap.c
pkcs12.c
pkcs5.c
pkparse.c
pkwrite.c
platform.c
platform_util.c
poly1305.c
psa_crypto.c
psa_crypto_aead.c
psa_crypto_cipher.c
psa_crypto_client.c
psa_crypto_ecp.c
psa_crypto_hash.c
psa_crypto_mac.c
psa_crypto_rsa.c
psa_crypto_se.c
psa_crypto_slot_management.c
psa_crypto_storage.c
psa_its_file.c
ripemd160.c
rsa.c
sha1.c
sha256.c
sha512.c
threading.c
timing.c
version.c
version_features.c
)
if (MBEDTLS_VERSION_MAJOR EQUAL 2)
list(APPEND src_crypto
arc4.c
blowfish.c
havege.c
md2.c
md4.c
psa_crypto_driver_wrappers.c
rsa_internal.c xtea.c
function(src_crypto_list)
set(src_crypto
aes.c
aesni.c
aria.c
asn1parse.c
asn1write.c
base64.c
bignum.c
camellia.c
ccm.c
chacha20.c
chachapoly.c
cipher.c
cipher_wrap.c
constant_time.c
cmac.c
ctr_drbg.c
des.c
dhm.c
ecdh.c
ecdsa.c
ecjpake.c
ecp.c
ecp_curves.c
entropy.c
entropy_poll.c
error.c
gcm.c
hkdf.c
hmac_drbg.c
md.c
md5.c
memory_buffer_alloc.c
mps_reader.c
mps_trace.c
nist_kw.c
oid.c
padlock.c
pem.c
pk.c
pk_wrap.c
pkcs12.c
pkcs5.c
pkparse.c
pkwrite.c
platform.c
platform_util.c
poly1305.c
psa_crypto.c
psa_crypto_aead.c
psa_crypto_cipher.c
psa_crypto_client.c
psa_crypto_ecp.c
psa_crypto_hash.c
psa_crypto_mac.c
psa_crypto_rsa.c
psa_crypto_se.c
psa_crypto_slot_management.c
psa_crypto_storage.c
psa_its_file.c
ripemd160.c
rsa.c
sha1.c
sha256.c
sha512.c
threading.c
timing.c
version.c
version_features.c
)
elseif (MBEDTLS_VERSION_MAJOR EQUAL 3)
list(APPEND src_crypto
bignum_core.c
rsa_alt_helpers.c
pk_ecc.c
)
endif()
list(TRANSFORM src_crypto PREPEND ${PICO_MBEDTLS_PATH}/library/)
if (MBEDTLS_VERSION_MAJOR EQUAL 2)
list(APPEND src_crypto
arc4.c
blowfish.c
havege.c
md2.c
md4.c
psa_crypto_driver_wrappers.c
rsa_internal.c xtea.c
)
elseif (MBEDTLS_VERSION_MAJOR EQUAL 3)
list(APPEND src_crypto
bignum_core.c
rsa_alt_helpers.c
pk_ecc.c
)
endif()
list(TRANSFORM src_crypto PREPEND ${PICO_MBEDTLS_PATH}/library/)
set(src_crypto ${src_crypto} PARENT_SCOPE)
endfunction()
src_crypto_list()
pico_add_library(pico_mbedtls_crypto NOFLAG)
target_sources(pico_mbedtls_crypto INTERFACE ${src_crypto})
set(src_x509
x509.c
x509_create.c
x509_crl.c
x509_crt.c
x509_csr.c
x509write_crt.c
x509write_csr.c
)
if (MBEDTLS_VERSION_MAJOR EQUAL 2)
list(APPEND src_x509
certs.c
pkcs11.c
function(src_x509_list)
set(src_x509
x509.c
x509_create.c
x509_crl.c
x509_crt.c
x509_csr.c
x509write_crt.c
x509write_csr.c
)
endif()
if (MBEDTLS_VERSION_MAJOR EQUAL 2)
list(APPEND src_x509
certs.c
pkcs11.c
)
endif()
list(TRANSFORM src_x509 PREPEND ${PICO_MBEDTLS_PATH}/library/)
set(src_x509 ${src_x509} PARENT_SCOPE)
endfunction()
list(TRANSFORM src_x509 PREPEND ${PICO_MBEDTLS_PATH}/library/)
src_x509_list()
pico_add_library(pico_mbedtls_x509 NOFLAG)
target_sources(pico_mbedtls_x509 INTERFACE ${src_x509})
set(src_tls
debug.c
net_sockets.c
ssl_cache.c
ssl_ciphersuites.c
ssl_cookie.c
ssl_msg.c
ssl_ticket.c
ssl_tls.c
ssl_tls13_keys.c
)
if (MBEDTLS_VERSION_MAJOR EQUAL 2)
list(APPEND src_tls
ssl_cli.c
ssl_srv.c
function(src_tls_list)
set(src_tls
debug.c
net_sockets.c
ssl_cache.c
ssl_ciphersuites.c
ssl_cookie.c
ssl_msg.c
ssl_ticket.c
ssl_tls.c
ssl_tls13_keys.c
)
elseif (MBEDTLS_VERSION_MAJOR EQUAL 3)
list(APPEND src_tls
ssl_client.c
ssl_debug_helpers_generated.c
ssl_tls12_client.c
ssl_tls12_server.c
)
endif()
if (MBEDTLS_VERSION_MAJOR EQUAL 2)
list(APPEND src_tls
ssl_cli.c
ssl_srv.c
)
elseif (MBEDTLS_VERSION_MAJOR EQUAL 3)
list(APPEND src_tls
ssl_client.c
ssl_debug_helpers_generated.c
ssl_tls12_client.c
ssl_tls12_server.c
)
endif()
list(TRANSFORM src_tls PREPEND ${PICO_MBEDTLS_PATH}/library/)
set(src_tls ${src_tls} PARENT_SCOPE)
endfunction()
list(TRANSFORM src_tls PREPEND ${PICO_MBEDTLS_PATH}/library/)
src_tls_list()
pico_add_library(pico_mbedtls_tls NOFLAG)
target_sources(pico_mbedtls_tls INTERFACE ${src_tls})
@ -187,32 +200,26 @@ if (EXISTS ${PICO_MBEDTLS_PATH}/${MBEDTLS_TEST_PATH})
target_include_directories(pico_mbedtls_headers SYSTEM INTERFACE ${PICO_MBEDTLS_PATH}/include/ ${PICO_MBEDTLS_PATH}/library/ ${CMAKE_CURRENT_LIST_DIR}/include/)
function(suppress_mbedtls_warnings)
# It seems everything needs this due to mbedtls_get_unaligned_uint64
src_crypto_list()
src_x509_list()
src_tls_list()
foreach(src_file IN LISTS src_crypto src_x509 src_tls)
set_source_files_properties(
${src_file}
PROPERTIES
COMPILE_OPTIONS "-Wno-cast-qual"
)
endforeach()
set_source_files_properties(
${PICO_MBEDTLS_PATH}/library/ecdsa.c
${PICO_MBEDTLS_PATH}/library/ecp.c
${PICO_MBEDTLS_PATH}/library/ecp_curves.c
${PICO_MBEDTLS_PATH}/library/pk_wrap.c
${PICO_MBEDTLS_PATH}/library/pkparse.c
${PICO_MBEDTLS_PATH}/library/ssl_cli.c
PROPERTIES
COMPILE_OPTIONS "-Wno-cast-qual"
)
set_source_files_properties(
${PICO_MBEDTLS_PATH}/library/psa_crypto_client.c
${PICO_MBEDTLS_PATH}/library/psa_crypto_driver_wrappers.c
PROPERTIES
COMPILE_OPTIONS "-Wno-redundant-decls"
)
set_source_files_properties(
${PICO_MBEDTLS_PATH}/library/ssl_srvx.c
${PICO_MBEDTLS_PATH}/library/x509_crt.c
PROPERTIES
COMPILE_OPTIONS "-Wno-cast-qual;-Wno-null-dereference"
)
set_source_files_properties(
${PICO_MBEDTLS_PATH}/library/ssl_srv.c
${PICO_MBEDTLS_PATH}/library/pk_ecc.c
${PICO_MBEDTLS_PATH}/library/ssl_tls12_server.c
${PICO_MBEDTLS_PATH}/library/ssl_tls.c
PROPERTIES
COMPILE_OPTIONS "-Wno-null-dereference"
COMPILE_OPTIONS "-Wno-cast-qual;-Wno-null-dereference"
)
endfunction()