diff --git a/src/supplemental/tls/mbedtls/CMakeLists.txt b/src/supplemental/tls/mbedtls/CMakeLists.txt index e3d767fcb..7e24e2992 100644 --- a/src/supplemental/tls/mbedtls/CMakeLists.txt +++ b/src/supplemental/tls/mbedtls/CMakeLists.txt @@ -25,12 +25,12 @@ if (NNG_TLS_ENGINE STREQUAL "mbed") else() # 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_PACKAGE_PREFER_CONFIG) + # what we do here. We only make this override locally, to + # avoid confounding any other package consumers, and we honor overrides. + if (NOT (DEFINED CMAKE_FIND_PACKAGE_PREFER_CONFIG)) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) find_package(MbedTLS REQUIRED) - set(CMAKE_FIND_PACKAGE_PREFER_CONFIG FALSE) + unset(CMAKE_FIND_PACKAGE_PREFER_CONFIG) else() find_package(MbedTLS REQUIRED) endif()