Skip to content

Commit

Permalink
(#16003) cxxopts: add version 3.1.1, update icu
Browse files Browse the repository at this point in the history
* cxxopts: add version 3.1.0, update icu

* remove unused import

* update 3.1.1

* Drop the oldest very for 2.0 to pass

* Drop older version for 2.0

---------

Co-authored-by: Chris Mc <[email protected]>
  • Loading branch information
toge and Chris Mc authored Mar 16, 2023
1 parent cbb1c27 commit 5b7bbc5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
6 changes: 3 additions & 3 deletions recipes/cxxopts/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"3.1.1":
url: "https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.1.1.tar.gz"
sha256: "523175f792eb0ff04f9e653c90746c12655f10cb70f1d5e6d6d9491420298a08"
"3.0.0":
url: "https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.0.0.tar.gz"
sha256: "36f41fa2a46b3c1466613b63f3fa73dc24d912bc90d667147f1e43215a8c6d00"
Expand All @@ -8,6 +11,3 @@ sources:
"2.2.0":
url: "https://github.com/jarro2783/cxxopts/archive/refs/tags/v2.2.0.tar.gz"
sha256: "447dbfc2361fce9742c5d1c9cfb25731c977b405f9085a738fbd608626da8a4d"
"1.4.4":
url: "https://github.com/jarro2783/cxxopts/archive/refs/tags/v1.4.4.tar.gz"
sha256: "1d0eedb39ecbc64a0f82d8b6fe40d5c8e611501702969cfbd14a07ce6ddb8501"
18 changes: 12 additions & 6 deletions recipes/cxxopts/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
import os

required_conan_version = ">=1.51.1"
Expand Down Expand Up @@ -34,6 +33,7 @@ def _min_cppstd(self):
def _minimum_compilers_version(self):
return {
"Visual Studio": "14",
"msvc": "190",
"gcc": "4.9",
"clang": "3.9",
"apple-clang": "8",
Expand All @@ -44,23 +44,29 @@ def layout(self):

def requirements(self):
if self.options.unicode:
self.requires("icu/71.1")
self.requires("icu/72.1")

def package_id(self):
self.info.clear()

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
min_version = self._minimum_compilers_version.get(str(self.settings.compiler))
if min_version and Version(self.settings.compiler.version) < min_version:

def loose_lt_semver(v1, v2):
lv1 = [int(v) for v in v1.split(".")]
lv2 = [int(v) for v in v2.split(".")]
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]

minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler), False)
if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version):
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support",
)

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def build(self):
pass
Expand Down
4 changes: 4 additions & 0 deletions recipes/cxxopts/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE cxxopts::cxxopts)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

if(cxxopts_VERSION VERSION_LESS "3.1.0")
target_compile_definitions(${PROJECT_NAME} PRIVATE CXXOPTS_OLD_EXCEPTIONS)
endif()

add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} -f 41 --bar baria --baz)
if(WITH_UNICODE)
# This will fail if it was not enabled in the package https://github.com/jarro2783/cxxopts#unrecognised-arguments
Expand Down
10 changes: 9 additions & 1 deletion recipes/cxxopts/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ int main(int argc, char* argv[])
std::cout << "qux:" << result["qux"].as<std::string>() << std::endl;
}
#endif
} catch (const cxxopts::OptionException& e) {
}
#ifdef CXXOPTS_OLD_EXCEPTIONS
catch (const cxxopts::OptionException& e) {
std::cout << "error parsing options: " << e.what() << std::endl;
return 1;
}
#else
catch (const cxxopts::exceptions::exception& e) {
std::cout << "error parsing options: " << e.what() << std::endl;
return 1;
}
#endif

return 0;
}
4 changes: 2 additions & 2 deletions recipes/cxxopts/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
versions:
"3.1.1":
folder: all
"3.0.0":
folder: all
"2.2.1":
folder: all
"2.2.0":
folder: all
"1.4.4":
folder: all

0 comments on commit 5b7bbc5

Please sign in to comment.