Repository: conan-io/conan-center-index

Issue:
[request] geographiclib/2.1.1
### Package Details
  * Package Name/Version: **geographiclib/2.1.1**
  * Changelog: **https://geographiclib.sourceforge.io/C++/doc/changes.html**

* Source-Link: https://github.com/geographiclib/geographiclib/tree/v2.1.1

The above mentioned version is newly released by the upstream project and not yet available as a recipe. Please add this version.



Discussion:
Do you really need 2.1.1, 2.1 and 2.0?
The newest version should also do the job. (and might be most useful for others as well)


I am working on something that requires 2.2
This has actually very quickly become a high priority need for us. I am only just starting to use Conan again after about 5 years of not using it, but I am going to take a stab at a PR for this. If someone who is more familiar can very quickly make the updates necessary then that would be deeply appreciated, but in the meantime I am going to run through the docs and see if I can get this working for v2.2.

Resolving patch:
diff --git a/recipes/geographiclib/all/conanfile.py b/recipes/geographiclib/all/conanfile.py
--- a/recipes/geographiclib/all/conanfile.py
+++ b/recipes/geographiclib/all/conanfile.py
@@ -65,10 +65,7 @@ def validate(self):
                 check_min_cppstd(self, 11)
 
             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]
+                return all(int(p1) < int(p2) for p1, p2 in zip(str(v1).split("."), str(v2).split(".")))
 
             minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
             if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version):
@@ -103,8 +100,9 @@ def generate(self):
     def _patch_sources(self):
         apply_conandata_patches(self)
         cmakelists = os.path.join(self.source_folder, "CMakeLists.txt")
-        # it does not work on Windows but is not needed
-        replace_in_file(self, cmakelists, "add_subdirectory (js)", "")
+        if Version(self.version) < "2":
+            # it does not work on Windows but is not needed
+            replace_in_file(self, cmakelists, "add_subdirectory (js)", "")
         # Don't install system libs
         replace_in_file(self, cmakelists, "include (InstallRequiredSystemLibraries)", "")
         # Don't build tools if asked
@@ -112,6 +110,9 @@ def _patch_sources(self):
             replace_in_file(self, cmakelists, "add_subdirectory (tools)", "")
             replace_in_file(self, os.path.join(self.source_folder, "cmake", "CMakeLists.txt"),
                                   "${TOOLS}", "")
+        # Disable -Werror
+        replace_in_file(self, cmakelists, "-Werror", "")
+        replace_in_file(self, cmakelists, "/WX", "")
 
     def build(self):
         self._patch_sources()


Test patch:
diff --git a/recipes/geographiclib/all/test_package/conanfile.py b/recipes/geographiclib/all/test_package/conanfile.py
--- a/recipes/geographiclib/all/test_package/conanfile.py
+++ b/recipes/geographiclib/all/test_package/conanfile.py
@@ -22,5 +22,5 @@ def build(self):
 
     def test(self):
         if can_run(self):
-            bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
+            bin_path = os.path.join(self.cpp.build.bindir, "test_package")
             self.run(bin_path, env="conanrun")