summaryrefslogtreecommitdiff
path: root/src/supplemental
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-01-27 14:22:36 -0800
committerGarrett D'Amore <garrett@damore.org>2024-01-27 16:55:14 -0800
commitf48959f1347d97a9bf4d5edb4eb0c46e4101d356 (patch)
treefc4ebd708026915db958c8c4167ab02bb2407cbf /src/supplemental
parent2f90e27f0b64990b99df1f4afdd9ea82ff512e61 (diff)
downloadnng-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')
-rw-r--r--src/supplemental/tls/mbedtls/CMakeLists.txt19
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()