-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for cpr 1.6.2 #5353
Changes from 1 commit
1214a12
01e2448
ea0f20a
c72da76
0c6ba8b
4cdb5a6
2505699
8d7b600
c660f6c
9509496
b99b4f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,12 +18,16 @@ class CprConan(ConanFile): | |||||
"fPIC": [True, False], | ||||||
"with_openssl": [True, False], | ||||||
"with_winssl": [True, False], | ||||||
"with_darwinssl": [True, False], | ||||||
"no_ssl": [True, False], | ||||||
} | ||||||
default_options = { | ||||||
"shared": False, | ||||||
"fPIC": True, | ||||||
"with_openssl": True, | ||||||
"with_winssl": False, | ||||||
"with_darwinssl": False, | ||||||
"no_ssl": False, | ||||||
} | ||||||
|
||||||
_cmake = None | ||||||
|
@@ -40,13 +44,23 @@ def _build_subfolder(self): | |||||
def _supports_openssl(self): | ||||||
# https://github.com/whoshuu/cpr/commit/b036a3279ba62720d1e43362d32202bf412ea152 | ||||||
# https://github.com/whoshuu/cpr/releases/tag/1.5.0 | ||||||
return tools.Version(self.version) >= "1.5.0" | ||||||
return tools.Version(self.version) >= "1.5.0" and not tools.is_apple_os(self.settings.os) | ||||||
|
||||||
@property | ||||||
def _supports_winssl(self): | ||||||
# https://github.com/whoshuu/cpr/commit/18e1fc5c3fc0ffc07695f1d78897fb69e7474ea9 | ||||||
# https://github.com/whoshuu/cpr/releases/tag/1.5.1 | ||||||
return tools.Version(self.version) >= "1.5.1" | ||||||
return tools.Version(self.version) >= "1.5.1" and self.settings.os == "Windows" | ||||||
|
||||||
@property | ||||||
def _supports_darwinssl(self): | ||||||
# https://github.com/whoshuu/cpr/releases/tag/1.6.1 | ||||||
return tools.Version(self.version) >= "1.6.1" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read this change and I could have SWORN I already did it. Guess not, lol. On it. |
||||||
|
||||||
@property | ||||||
def _can_disable_ssl(self): | ||||||
# https://github.com/whoshuu/cpr/releases/tag/1.6.0 | ||||||
return not self._uses_old_cmake_options | ||||||
|
||||||
@property | ||||||
def _uses_old_cmake_options(self): | ||||||
|
@@ -74,6 +88,8 @@ def configure(self): | |||||
del self.options.with_openssl | ||||||
if not self._supports_winssl: | ||||||
del self.options.with_winssl | ||||||
if not self._supports_darwinssl: | ||||||
del self.options.with_darwinssl | ||||||
|
||||||
# Make sure libcurl uses the same SSL implementation | ||||||
if self.options.get_safe("with_openssl", False): | ||||||
|
@@ -82,6 +98,8 @@ def configure(self): | |||||
if self.options.get_safe("with_winssl", False): | ||||||
# self.options["libcurl"].with_winssl = True # deprecated in https://github.com/conan-io/conan-center-index/pull/2880 | ||||||
self.options["libcurl"].with_ssl = "schannel" | ||||||
if self.options.get_safe("with_darwinssl", False): | ||||||
self.options["libcurl"].with_ssl = "darwinssl" | ||||||
|
||||||
|
||||||
def source(self): | ||||||
|
@@ -120,27 +138,38 @@ def _configure_cmake(self): | |||||
self._cmake.definitions[self._get_cmake_option("CPR_BUILD_TESTS")] = False | ||||||
self._cmake.definitions[self._get_cmake_option("CPR_GENERATE_COVERAGE")] = False | ||||||
self._cmake.definitions[self._get_cmake_option("CPR_USE_SYSTEM_GTEST")] = False | ||||||
|
||||||
if self._supports_openssl: | ||||||
self._cmake.definitions["CMAKE_USE_OPENSSL"] = self.options.get_safe("with_openssl", False) | ||||||
|
||||||
if self._supports_darwinssl: | ||||||
self._cmake.definitions[self._get_cmake_option("CPR_FORCE_DARWINSSL_BACKEND")] = self.options.get_safe("with_darwinssl", False) | ||||||
|
||||||
if self._supports_winssl: # The CMake options changed | ||||||
# https://github.com/whoshuu/cpr/commit/18e1fc5c3fc0ffc07695f1d78897fb69e7474ea9#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR39-R40 | ||||||
self._cmake.definitions[self._get_cmake_option("CPR_FORCE_OPENSSL_BACKEND")] = self.options.get_safe("with_openssl", False) | ||||||
self._cmake.definitions[self._get_cmake_option("CPR_FORCE_WINSSL_BACKEND")] = self.options.get_safe("with_winssl", False) | ||||||
|
||||||
supports_any_ssl = self.options.get_safe("with_openssl", False) or self.options.get_safe("with_winssl", False) | ||||||
if not self._uses_old_cmake_options and not supports_any_ssl: | ||||||
if self._can_disable_ssl and self.options.get_safe("no_ssl", False): | ||||||
self._cmake.definitions["CPR_ENABLE_SSL"] = False | ||||||
self._cmake.configure(build_folder=self._build_subfolder) | ||||||
return self._cmake | ||||||
|
||||||
def validate(self): | ||||||
if not self._uses_valid_abi_and_compiler: | ||||||
raise ConanInvalidConfiguration("Cannot compile CPR/1.6.0 with libstdc++ on clang < 9") | ||||||
raise ConanInvalidConfiguration("Cannot compile cpr/1.6.0 with libstdc++ on clang < 9") | ||||||
|
||||||
if not self._can_disable_ssl and self.options.get_safe("no_ssl", False): | ||||||
# https://github.com/whoshuu/cpr/issues/546 | ||||||
raise ConanInvalidConfiguration("cpr < 1.6.0 cannot manually disable SSL.") | ||||||
|
||||||
if self.options.get_safe("with_openssl", False) and tools.is_apple_os(self.settings.os): | ||||||
# https://github.com/whoshuu/cpr/issues/546 | ||||||
raise ConanInvalidConfiguration("cpr cannot be built on macOS with openssl") | ||||||
|
||||||
if self.options.get_safe("with_darwinssl", False) and not tools.is_apple_os(self.settings.os): | ||||||
raise ConanInvalidConfiguration("cpr only supports darwinssl on macOS") | ||||||
|
||||||
if self.options.get_safe("with_winssl", False) and self.settings.os != "Windows": | ||||||
raise ConanInvalidConfiguration("cpr only supports winssl on Windows") | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -120,29 +120,11 @@ endif() | ||
|
||
# Curl configuration | ||
if(CPR_FORCE_USE_SYSTEM_CURL) | ||
- if(CPR_ENABLE_SSL) | ||
- find_package(CURL COMPONENTS HTTP HTTPS SSL) | ||
- if(CURL_FOUND) | ||
- message(STATUS "Curl ${CURL_VERSION_STRING} found on this system.") | ||
- # To be able to load certificates under Windows when using OpenSSL: | ||
- if(CMAKE_USE_OPENSSL AND WIN32 AND (NOT (CURL_VERSION_STRING VERSION_GREATER_EQUAL "7.71.0"))) | ||
- message(FATAL_ERROR "Your system curl version (${CURL_VERSION_STRING}) is too old to support OpenSSL on Windows which requires curl >= 7.71.0. Update your curl version, use WinSSL, disable SSL or use the build in version of curl.") | ||
- endif() | ||
- else() | ||
- find_package(CURL COMPONENTS HTTP) | ||
- if(CURL_FOUND) | ||
- message(FATAL_ERROR "Curl found on this system but WITHOUT HTTPS/SSL support. Either disable SSL by setting CPR_ENABLE_SSL to OFF or use the build in version of curl by setting CPR_FORCE_USE_SYSTEM_CURL to OFF.") | ||
- else() | ||
- message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") | ||
- endif() | ||
- endif() | ||
+ find_package(CURL) | ||
+ if(CURL_FOUND) | ||
+ message(STATUS "Curl found on this system.") | ||
else() | ||
- find_package(CURL COMPONENTS HTTP) | ||
- if(CURL_FOUND) | ||
- message(STATUS "Curl found on this system.") | ||
- else() | ||
- message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") | ||
- endif() | ||
+ message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use find_package(REQUIRED) here? |
||
else() | ||
message(STATUS "Configuring build in curl...") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ versions: | |
folder: all | ||
"1.6.0": | ||
folder: all | ||
"1.6.2": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was afraid of this...
Can we copy the curl recipe and use an
with_ssl
and provide string options? and deprecate the older two?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, that makes total sense, and frankly I don't know why I didn't think about it. Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a proper way to deprecate options, by the way? I took a quick peek at the docs and didn't see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#5020 We just wrote it recently 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh awesome! Will flip to using that way