diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-01-27 14:22:36 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-01-27 16:55:14 -0800 |
| commit | f48959f1347d97a9bf4d5edb4eb0c46e4101d356 (patch) | |
| tree | fc4ebd708026915db958c8c4167ab02bb2407cbf /src/supplemental/tls | |
| parent | 2f90e27f0b64990b99df1f4afdd9ea82ff512e61 (diff) | |
| download | nng-f48959f1347d97a9bf4d5edb4eb0c46e4101d356.tar.gz nng-f48959f1347d97a9bf4d5edb4eb0c46e4101d356.tar.bz2 nng-f48959f1347d97a9bf4d5edb4eb0c46e4101d356.zip | |
Mbed TLS CMake improvements.
Try to use the Mbed TLS cmake configuration data if present, and
refactor our FindModule to adhere to the same basic API.
Diffstat (limited to 'src/supplemental/tls')
| -rw-r--r-- | src/supplemental/tls/mbedtls/CMakeLists.txt | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/supplemental/tls/mbedtls/CMakeLists.txt b/src/supplemental/tls/mbedtls/CMakeLists.txt index 2d639efa..fda226e5 100644 --- a/src/supplemental/tls/mbedtls/CMakeLists.txt +++ b/src/supplemental/tls/mbedtls/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +# Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> # # This software is supplied under the terms of the MIT License, a # copy of which should be located in the distribution where this @@ -10,7 +10,7 @@ if (NNG_TLS_ENGINE STREQUAL "mbed") message(WARNING " ************************************************************ - Linking against Mbed TLS changes license terms (Apache 2.0). + Linking against Mbed TLS may change license terms. Consult a lawyer and the license files for details. ************************************************************") nng_sources(tls.c) @@ -23,8 +23,17 @@ if (NNG_TLS_ENGINE STREQUAL "mbed") if (TARGET mbedtls) nng_link_libraries(mbedtls) else() - nng_find_package(mbedTLS) - nng_link_libraries(${MBEDTLS_LIBRARIES}) - nng_include_directories(${MBEDTLS_INCLUDE_DIR}) + # We want to prefer config mode over our local find package. + # mbedTLS v3 has a config file, which should work better than + # what we do here. We do restore the setting though because + # user applications might not expect this. + if (NOT CMAKE_FIND_PAKCAGE_PREFER_CONFIG) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) + find_package(MbedTLS REQUIRED) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG FALSE) + else() + find_package(MbedTLS REQUIRED) + endif() + nng_link_libraries_public(MbedTLS::mbedtls MbedTLS::mbedcrypto MbedTLS::mbedx509) endif() endif() |
