2525#
2626# Input variables:
2727#
28- # - `MBEDTLS_INCLUDE_DIR`: Absolute path to mbedTLS include directory.
29- # - `MBEDTLS_LIBRARY`: Absolute path to `mbedtls` library.
30- # - `MBEDX509_LIBRARY`: Absolute path to `mbedx509` library.
31- # - `MBEDCRYPTO_LIBRARY`: Absolute path to `mbedcrypto` library.
28+ # - `MBEDTLS_INCLUDE_DIR`: Absolute path to mbedTLS include directory.
29+ # - `MBEDTLS_LIBRARY`: Absolute path to `mbedtls` library.
30+ # - `MBEDX509_LIBRARY`: Absolute path to `mbedx509` library.
31+ # - `MBEDCRYPTO_LIBRARY`: Absolute path to `mbedcrypto` library.
32+ # - `MBEDTLS_USE_STATIC_LIBS`: Configure for static mbedTLS libraries.
3233#
3334# Defines:
3435#
35- # - `MBEDTLS_FOUND`: System has mbedTLS.
36- # - `MBEDTLS_VERSION`: Version of mbedTLS.
37- # - `CURL::mbedtls`: mbedTLS library target.
36+ # - `MBEDTLS_FOUND`: System has mbedTLS.
37+ # - `MBEDTLS_VERSION`: Version of mbedTLS.
38+ # - `CURL::mbedtls`: mbedTLS library target.
3839
3940if (DEFINED MBEDTLS_INCLUDE_DIRS AND NOT DEFINED MBEDTLS_INCLUDE_DIR)
4041 message (WARNING "MBEDTLS_INCLUDE_DIRS is deprecated, use MBEDTLS_INCLUDE_DIR instead." )
@@ -57,14 +58,27 @@ if(_mbedtls_FOUND)
5758 set (MbedTLS_FOUND TRUE )
5859 set (MBEDTLS_FOUND TRUE )
5960 set (MBEDTLS_VERSION ${_mbedtls_mbedtls_VERSION} )
61+ if (MBEDTLS_USE_STATIC_LIBS)
62+ set (_mbedtls_CFLAGS "${_mbedtls_STATIC_CFLAGS} " )
63+ set (_mbedtls_INCLUDE_DIRS "${_mbedtls_STATIC_INCLUDE_DIRS} " )
64+ set (_mbedtls_LIBRARY_DIRS "${_mbedtls_STATIC_LIBRARY_DIRS} " )
65+ set (_mbedtls_LIBRARIES "${_mbedtls_STATIC_LIBRARIES} " )
66+ endif ()
6067 message (STATUS "Found MbedTLS (via pkg-config): ${_mbedtls_INCLUDE_DIRS} (found version \" ${MBEDTLS_VERSION} \" )" )
6168else ()
6269 set (_mbedtls_pc_requires "" ) # Depend on pkg-config only when found via pkg-config
6370
6471 find_path (MBEDTLS_INCLUDE_DIR NAMES "mbedtls/ssl.h" )
65- find_library (MBEDTLS_LIBRARY NAMES "mbedtls" "libmbedtls" )
66- find_library (MBEDX509_LIBRARY NAMES "mbedx509" "libmbedx509" )
67- find_library (MBEDCRYPTO_LIBRARY NAMES "mbedcrypto" "libmbedcrypto" )
72+ if (MBEDTLS_USE_STATIC_LIBS)
73+ find_library (MBEDTLS_LIBRARY NAMES "mbedtls_static" "libmbedtls_static" "mbedtls" "libmbedtls" )
74+ find_library (MBEDX509_LIBRARY NAMES "mbedx509_static" "libmbedx509_static" "mbedx509" "libmbedx509" )
75+ find_library (MBEDCRYPTO_LIBRARY NAMES "mbedcrypto_static" "libmbedcrypto_static" "mbedcrypto" "libmbedcrypto"
76+ "tfpsacrypto_static" "libtfpsacrypto_static" "tfpsacrypto" "libtfpsacrypto" )
77+ else ()
78+ find_library (MBEDTLS_LIBRARY NAMES "mbedtls" "libmbedtls" )
79+ find_library (MBEDX509_LIBRARY NAMES "mbedx509" "libmbedx509" )
80+ find_library (MBEDCRYPTO_LIBRARY NAMES "mbedcrypto" "libmbedcrypto" "tfpsacrypto" "libtfpsacrypto" )
81+ endif ()
6882
6983 unset (MBEDTLS_VERSION CACHE )
7084 if (MBEDTLS_INCLUDE_DIR AND EXISTS "${MBEDTLS_INCLUDE_DIR} /mbedtls/build_info.h" )
0 commit comments