Repository: conan-io/conan-center-index

Issue:
version bump to 2.23.0
Specify library name and version:  **mbedtls/2.23.0**

- [x] I've read the [guidelines](https://github.com/conan-io/conan-center-index/wiki#how-to-submit-a-pull-request) for contributing.
- [x] I've followed the [PEP8](https://www.python.org/dev/peps/pep-0008/) style guides for Python code in the recipes.
- [x] I've used the [latest](https://github.com/conan-io/conan/releases/latest) Conan client version.
- [x] I've tried at least one configuration locally with the
      [conan-center hook](https://github.com/conan-io/hooks.git) activated.




Discussion:

Resolving patch:
diff --git a/recipes/mbedtls/all/conanfile.py b/recipes/mbedtls/all/conanfile.py
--- a/recipes/mbedtls/all/conanfile.py
+++ b/recipes/mbedtls/all/conanfile.py
@@ -1,4 +1,5 @@
 from conans import CMake, ConanFile, tools
+from conans.errors import ConanInvalidConfiguration
 import os
 
 
@@ -12,17 +13,14 @@ class MBedTLSConan(ConanFile):
     exports_sources = "CMakeLists.txt", "patches/**"
     generators = "cmake"
     settings = "os", "compiler", "build_type", "arch"
-    options = {
-        "shared": [True, False],
-        "fPIC": [True, False],
-        "with_zlib": [True, False],
-    }
-    default_options = {
-        "shared": False,
-        "fPIC": True,
-        "with_zlib": True,
-    }
-    _source_subfolder = "source_subfolder"
+    options = {"shared": [True, False], "fPIC": [True, False], "with_zlib": [True, False]}
+    default_options = {"shared": False, "fPIC": True, "with_zlib": True}
+
+    _cmake = None
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
 
     @property
     def _version(self):
@@ -33,12 +31,26 @@ def _license(self):
         return self.version.rsplit("-", 1)[1]
 
     def config_options(self):
-        if self.settings.os == "Windows" or self.options.shared:
+        if self.settings.os == "Windows":
             del self.options.fPIC
 
     def configure(self):
+        if self.options.shared:
+            del self.options.fPIC
         del self.settings.compiler.cppstd
         del self.settings.compiler.libcxx
+        if tools.Version(self.version) >= "2.23.0":
+            self.license = "Apache-2.0"
+
+        if tools.Version(self.version) == "2.23.0" \
+            and self.settings.os == "Windows" and self.options.shared:
+            raise ConanInvalidConfiguration(
+                "{}/{} does not support shared build on Windows".format(self.name, self.version))
+
+        if tools.Version(self.version) == "2.23.0" \
+            and self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5":
+            # The command line flags set are not supported on older versions of gcc
+            raise ConanInvalidConfiguration("{}-{} is not supported by this recipe".format(self.settings.compiler, self.settings.compiler.version))
 
     def requirements(self):
         if self.options.with_zlib:
@@ -47,39 +59,40 @@ def requirements(self):
     def source(self):
         tools.get(**self.conan_data["sources"][self.version])
         extracted_dir = "{}-{}".format(self.name, self._version)
+        if tools.Version(self.version) >= "2.23.0": # went to mbedtls-mbedtls-X.X.X
+            extracted_dir = "{}-{}".format(self.name, extracted_dir)
         os.rename(extracted_dir, self._source_subfolder)
 
     def _configure_cmake(self):
-        cmake = CMake(self)
-        cmake.definitions["USE_SHARED_MBEDTLS_LIBRARY"] = self.options.shared
-        cmake.definitions["USE_STATIC_MBEDTLS_LIBRARY"] = not self.options.shared
-        cmake.definitions["ENABLE_ZLIB_SUPPORT"] = self.options.with_zlib
-        cmake.definitions["ENABLE_PROGRAMS"] = False
-        cmake.definitions["ENABLE_TESTING"] = False
-
-        cmake.configure()
-
-        return cmake
+        if not self._cmake:
+            self._cmake = CMake(self)
+            self._cmake.definitions["USE_SHARED_MBEDTLS_LIBRARY"] = self.options.shared
+            self._cmake.definitions["USE_STATIC_MBEDTLS_LIBRARY"] = not self.options.shared
+            self._cmake.definitions["ENABLE_ZLIB_SUPPORT"] = self.options.with_zlib
+            self._cmake.definitions["ENABLE_PROGRAMS"] = False
+            self._cmake.definitions["ENABLE_TESTING"] = False
+            self._cmake.configure()
+        return self._cmake
 
     def build(self):
-        for patch in self.conan_data["patches"][self.version]:
+        for patch in self.conan_data.get("patches", {}).get(self.version, []):
             tools.patch(**patch)
-
         cmake = self._configure_cmake()
         cmake.build()
 
     def package(self):
         self.copy("LICENSE", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses")
-        if self._license == "gpl":
-            self.copy("gpl-2.0.txt", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses")
-        else:
-            self.copy("apache-2.0.txt", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses")
+        if tools.Version(self.version) < "2.23.0": # less then 2.23 is multi-licensed
+            if self._license == "gpl":
+                self.copy("gpl-2.0.txt", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses")
+            else:
+                self.copy("apache-2.0.txt", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses")
         cmake = self._configure_cmake()
         cmake.install()
-
         tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
 
     def package_info(self):
+        # https://gitlab.kitware.com/cmake/cmake/blob/de7c21d677db1ddaeece03c19e13e448f4031511/CMakeLists.txt#L380
         self.cpp_info.names["cmake_find_package"] = "MbedTLS"
         self.cpp_info.names["cmake_find_package_multi"] = "MbedTLS"
-        self.cpp_info.libs = ["mbedtls", "mbedx509", "mbedcrypto", ]
+        self.cpp_info.libs = ["mbedtls", "mbedx509", "mbedcrypto"]


Test patch:
diff --git a/recipes/mbedtls/all/test_package/CMakeLists.txt b/recipes/mbedtls/all/test_package/CMakeLists.txt
--- a/recipes/mbedtls/all/test_package/CMakeLists.txt
+++ b/recipes/mbedtls/all/test_package/CMakeLists.txt
@@ -1,8 +1,10 @@
-cmake_minimum_required(VERSION 2.8.11)
+cmake_minimum_required(VERSION 3.1)
 project(test_package)
 
 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
 conan_basic_setup()
 
+find_package(MbedTLS REQUIRED)
+
 add_executable(${PROJECT_NAME} test_package.cpp)
-target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
+target_link_libraries(${PROJECT_NAME} MbedTLS::MbedTLS)
diff --git a/recipes/mbedtls/all/test_package/conanfile.py b/recipes/mbedtls/all/test_package/conanfile.py
--- a/recipes/mbedtls/all/test_package/conanfile.py
+++ b/recipes/mbedtls/all/test_package/conanfile.py
@@ -4,7 +4,7 @@
 
 class TestPackageConan(ConanFile):
     settings = "os", "compiler", "build_type", "arch"
-    generators = "cmake"
+    generators = "cmake", "cmake_find_package"
 
     def build(self):
         cmake = CMake(self)