Repository: conan-io/conan-center-index

Issue:
[package] libcurl/7.66.0 WinSSL not enabled with CMake build
I'm trying to build libcurl/7.66.0 with WINSSL option enabled for my project. But option is disabled in CMakeCache.txt after building is done.
Recipe libcurl/7.66.0 (Latest Revision be0504c6acf1da62622a18855ce40cb2) trying to set only CMAKE_USE_SCHANNEL while configuring CMake. And it does not set CMAKE_USE_WINSSL

It doesn't matter if I use Recipe's option `:with_winssl=True` or `:with_ssl=schannel`. The first one only results in warning:
 _libcurl/7.66.0: WARN: with_openssl, with_winssl, darwin_ssl and with_wolfssl options are deprecated. Use with_ssl option instead._

libcurl-7.66 does not have an option CMAKE_USE_SCHANNEL in CMakeLists.txt. The option was added in later versions. 
There is only option CMAKE_USE_WINSSL and  variables: SSL_ENABLED, USE_SCHANNEL, USE_WINDOWS_SSPI depending on it.
```
if(CMAKE_USE_WINSSL)
  set(SSL_ENABLED ON)
  set(USE_SCHANNEL ON) # Windows native SSL/TLS support
  set(USE_WINDOWS_SSPI ON) # CMAKE_USE_WINSSL implies CURL_WINDOWS_SSPI
  list(APPEND CURL_LIBS "crypt32")
endif()
```

Generated CMakeCache.txt:
```
//No help, variable specified on the command line.
CMAKE_USE_SCHANNEL:UNINITIALIZED=True

//enable Windows native SSL/TLS
CMAKE_USE_WINSSL:BOOL=OFF
```


**Environment details:**
Operation system: Windows 10
Conan version 1.31.2

Profile msvc16StaticDebug64:
```
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
compiler.runtime=MTd
build_type=Debug
[options]
[build_requires]
[env]

```
My conanfile.txt:
```
[requires]
libcurl/7.66.0

[generators]
cmake_find_package

[options]
libcurl:with_ssl=schannel
```

**Step to reproduce:**
conan install --profile msvc16StaticDebug64 --build=missing ..\conanfile.txt




Discussion:
Can anyone suggest how to set specific revision of package Recipe in conanfile.txt?
I found that the last Recipe which set the CMAKE_USE_WINSSL option is _27fb52e6411dc107de4b121c55a46ae5_
The `CMakeLists.txt` of libcurl 7.74.0 has the following line:
```
if(CMAKE_USE_WINSSL)
  message(FATAL_ERROR "The cmake option CMAKE_USE_WINSSL was renamed to CMAKE_USE_SCHANNEL.")
endif()
```

(I checked and 7.66.0 has it too)

Resolving patch:
diff --git a/recipes/libcurl/all/conanfile.py b/recipes/libcurl/all/conanfile.py
--- a/recipes/libcurl/all/conanfile.py
+++ b/recipes/libcurl/all/conanfile.py
@@ -17,46 +17,48 @@ class LibcurlConan(ConanFile):
     generators = "cmake", "cmake_find_package_multi", "pkg_config"
 
     settings = "os", "arch", "compiler", "build_type"
-    options = {"shared": [True, False],
-               "fPIC": [True, False],
-               "with_ssl": [False, "openssl", "wolfssl", "schannel", "darwinssl"],
-               "with_openssl": [True, False, "deprecated"],
-               "with_wolfssl": [True, False, "deprecated"],
-               "with_winssl": [True, False, "deprecated"],
-               "darwin_ssl": [True, False, "deprecated"],
-               "with_ldap": [True, False],
-               "with_libssh2": [True, False],
-               "with_libidn": [True, False],
-               "with_librtmp": [True, False],
-               "with_libmetalink": [True, False],
-               "with_libpsl": [True, False],
-               "with_largemaxwritesize": [True, False],
-               "with_nghttp2": [True, False],
-               "with_zlib": [True, False],
-               "with_brotli": [True, False],
-               "with_zstd": [True, False],
-               "with_c_ares": [True, False],
-               }
-    default_options = {"shared": False,
-                       "fPIC": True,
-                       "with_ssl": "openssl",
-                       "with_openssl": "deprecated",
-                       "with_wolfssl": "deprecated",
-                       "with_winssl": "deprecated",
-                       "darwin_ssl": "deprecated",
-                       "with_ldap": False,
-                       "with_libssh2": False,
-                       "with_libidn": False,
-                       "with_librtmp": False,
-                       "with_libmetalink": False,
-                       "with_libpsl": False,
-                       "with_largemaxwritesize": False,
-                       "with_nghttp2": False,
-                       "with_zlib": True,
-                       "with_brotli": False,
-                       "with_zstd": False,
-                       "with_c_ares": False,
-                       }
+    options = {
+        "shared": [True, False],
+        "fPIC": [True, False],
+        "with_ssl": [False, "openssl", "wolfssl", "schannel", "darwinssl"],
+        "with_openssl": [True, False, "deprecated"],
+        "with_wolfssl": [True, False, "deprecated"],
+        "with_winssl": [True, False, "deprecated"],
+        "darwin_ssl": [True, False, "deprecated"],
+        "with_ldap": [True, False],
+        "with_libssh2": [True, False],
+        "with_libidn": [True, False],
+        "with_librtmp": [True, False],
+        "with_libmetalink": [True, False],
+        "with_libpsl": [True, False],
+        "with_largemaxwritesize": [True, False],
+        "with_nghttp2": [True, False],
+        "with_zlib": [True, False],
+        "with_brotli": [True, False],
+        "with_zstd": [True, False],
+        "with_c_ares": [True, False],
+    }
+    default_options = {
+        "shared": False,
+        "fPIC": True,
+        "with_ssl": "openssl",
+        "with_openssl": "deprecated",
+        "with_wolfssl": "deprecated",
+        "with_winssl": "deprecated",
+        "darwin_ssl": "deprecated",
+        "with_ldap": False,
+        "with_libssh2": False,
+        "with_libidn": False,
+        "with_librtmp": False,
+        "with_libmetalink": False,
+        "with_libpsl": False,
+        "with_largemaxwritesize": False,
+        "with_nghttp2": False,
+        "with_zlib": True,
+        "with_brotli": False,
+        "with_zstd": False,
+        "with_c_ares": False,
+    }
 
     _autotools = None
     _autotools_vars = None
@@ -140,7 +142,7 @@ def configure(self):
 
     def requirements(self):
         if self.options.with_ssl == "openssl":
-            self.requires("openssl/1.1.1h")
+            self.requires("openssl/1.1.1i")
         elif self.options.with_ssl == "wolfssl":
             self.requires("wolfssl/4.5.0")
         if self.options.with_nghttp2:
@@ -152,7 +154,7 @@ def requirements(self):
         if self.options.with_brotli:
             self.requires("brotli/1.0.9")
         if self.options.get_safe("with_zstd"):
-            self.requires("zstd/1.4.5")
+            self.requires("zstd/1.4.8")
         if self.options.with_c_ares:
             self.requires("c-ares/1.17.1")
 
@@ -221,25 +223,30 @@ def _patch_misc_files(self):
                                   "if(UNIX)", "if(TRUE)")
 
     def _get_configure_command_args(self):
-        params = []
-        params.append("--without-libidn2" if not self.options.with_libidn else "--with-libidn2")
-        params.append("--without-librtmp" if not self.options.with_librtmp else "--with-librtmp")
-        params.append("--without-libmetalink" if not self.options.with_libmetalink else "--with-libmetalink")
-        params.append("--without-libpsl" if not self.options.with_libpsl else "--with-libpsl")
-
+        yes_no = lambda v: "yes" if v else "no"
+        params = [
+            "--with-libidn2={}".format(yes_no(self.options.with_libidn)),
+            "--with-librtmp={}".format(yes_no(self.options.with_librtmp)),
+            "--with-libmetalink={}".format(yes_no(self.options.with_libmetalink)),
+            "--with-libpsl={}".format(yes_no(self.options.with_libpsl)),
+            "--with-schannel={}".format(yes_no(self.options.with_ssl == "schannel")),
+            "--with-darwinssl={}".format(yes_no(self.options.with_ssl == "darwinssl")),
+            "--with-brotli={}".format(yes_no(self.options.with_brotli)),
+            "--enable-shared={}".format(yes_no(self.options.shared)),
+            "--enable-static={}".format(yes_no(not self.options.shared)),
+            "--enable-ldap={}".format(yes_no(self.options.with_ldap)),
+            "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")),
+            "--enable-ares={}".format(yes_no(self.options.with_c_ares)),
+            "--enable-threaded-resolver={}".format(yes_no(self.options.with_c_ares)),
+        ]
         if self.options.with_ssl == "openssl":
             params.append("--with-ssl={}".format(tools.unix_path(self.deps_cpp_info["openssl"].rootpath)))
-        elif self.options.with_ssl == "wolfssl":
-            params.append("--with-wolfssl={}".format(tools.unix_path(self.deps_cpp_info["wolfssl"].rootpath)))
-            params.append("--without-ssl")
-        elif self.options.with_ssl == "schannel":
-            params.append("--with-schannel")
-            params.append("--without-ssl")
-        elif self.options.with_ssl == "darwinssl":
-            params.append("--with-darwinssl")
-            params.append("--without-ssl")
         else:
             params.append("--without-ssl")
+        if self.options.with_ssl == "wolfssl":
+            params.append("--with-wolfssl={}".format(tools.unix_path(self.deps_cpp_info["wolfssl"].rootpath)))
+        else:
+            params.append("--without-wolfssl")
 
         if self.options.with_libssh2:
             params.append("--with-libssh2={}".format(tools.unix_path(self.deps_cpp_info["libssh2"].lib_paths[0])))
@@ -256,27 +263,8 @@ def _get_configure_command_args(self):
         else:
             params.append("--without-zlib")
 
-        params.append("--with-brotli" if self.options.with_brotli else "--without-brotli")
-
         if self._has_zstd_option:
-            params.append("--with-zstd" if self.options.with_zstd else "--without-zstd")
-
-        if not self.options.shared:
-            params.append("--disable-shared")
-            params.append("--enable-static")
-        else:
-            params.append("--enable-shared")
-            params.append("--disable-static")
-
-        if not self.options.with_ldap:
-            params.append("--disable-ldap")
-
-        if self.settings.build_type == "Debug":
-           params.append("--enable-debug")
-
-        if self.options.with_c_ares:
-            params.append("--enable-ares")
-            params.append("--enable-threaded-resolver")
+            params.append("--with-zstd={}".format(yes_no(self.options.with_zstd)))
 
         # Cross building flags
         if tools.cross_building(self.settings):
@@ -484,7 +472,10 @@ def _configure_cmake(self):
         self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
         self._cmake.definitions["CURL_STATICLIB"] = not self.options.shared
         self._cmake.definitions["CMAKE_DEBUG_POSTFIX"] = ""
-        self._cmake.definitions["CMAKE_USE_SCHANNEL"] = self.options.with_ssl == "schannel"
+        if tools.Version(self.version) >= "7.72.0":
+            self._cmake.definitions["CMAKE_USE_SCHANNEL"] = self.options.with_ssl == "schannel"
+        else:
+            self._cmake.definitions["CMAKE_USE_WINSSL"] = self.options.with_ssl == "schannel"
         self._cmake.definitions["CMAKE_USE_OPENSSL"] = self.options.with_ssl == "openssl"
         if tools.Version(self.version) >= "7.70.0":
             self._cmake.definitions["CMAKE_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl"
@@ -558,7 +549,7 @@ def package_info(self):
             if self.options.with_ldap:
                 self.cpp_info.components["curl"].system_libs.append("wldap32")
             if self.options.with_ssl == "schannel":
-                self.cpp_info.components["curl"].system_libs.append("Crypt32")
+                self.cpp_info.components["curl"].system_libs.append("crypt32")
         elif self.settings.os == "Macos":
             if self.options.with_ldap:
                 self.cpp_info.components["curl"].system_libs.append("ldap")


Test patch: