Repository: conan-io/conan-center-index

Issue:
[request] gmp/6.2.0
### Package Details
  * Package Name/Version: **gmp/6.2.0**
  * Changelog: **https://gmplib.org**


The above mentioned version is newly released by the upstream project and not yet available as a recipe. Please add this version.



Discussion:

Resolving patch:
diff --git a/recipes/gmp/all/conanfile.py b/recipes/gmp/all/conanfile.py
--- a/recipes/gmp/all/conanfile.py
+++ b/recipes/gmp/all/conanfile.py
@@ -69,19 +69,24 @@ def package(self):
         with tools.chdir(self._source_subfolder):
             autotools = self._configure_autotools()
             autotools.install()
+
+        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
         tools.rmdir(os.path.join(self.package_folder, "share"))
-        # remove la files
-        for la_name in ['libgmp.la', 'libgmpxx.la']:
-            la = os.path.join(self.package_folder, "lib", la_name)
-            if os.path.isfile(la):
-                os.unlink(la)
+        os.unlink(os.path.join(self.package_folder, "lib", "libgmp.la"))
+        if self.options.enable_cxx:
+            os.unlink(os.path.join(self.package_folder, "lib", "libgmpxx.la"))
 
     def package_id(self):
         del self.info.options.run_checks  # run_checks doesn't affect package's ID
 
     def package_info(self):
+        self.cpp_info.components["libgmp"].libs = ["gmp"]
+        self.cpp_info.components["libgmp"].names["cmake_find_package"] = "GMP"
+        self.cpp_info.components["libgmp"].names["cmake_find_package_multi"] = "GMP"
+        self.cpp_info.components["libgmp"].names["pkg_config"] = "gmp"
         if self.options.enable_cxx:
-            self.cpp_info.libs = ["gmpxx"]
-        self.cpp_info.libs.append("gmp")
-        self.cpp_info.names["cmake_find_package"] = "GMP"
-        self.cpp_info.names["cmake_find_package_multi"] = "GMP"
+            self.cpp_info.components["gmpxx"].libs = ["gmpxx"]
+            self.cpp_info.components["gmpxx"].requires = ["libgmp"]
+            self.cpp_info.components["gmpxx"].names["cmake_find_package"] = "GMPXX"
+            self.cpp_info.components["gmpxx"].names["cmake_find_package_multi"] = "GMPXX"
+            self.cpp_info.components["gmpxx"].names["pkg_config"] = "gmpxx"


Test patch:
diff --git a/recipes/gmp/all/test_package/CMakeLists.txt b/recipes/gmp/all/test_package/CMakeLists.txt
--- a/recipes/gmp/all/test_package/CMakeLists.txt
+++ b/recipes/gmp/all/test_package/CMakeLists.txt
@@ -10,5 +10,4 @@ target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
 if (ENABLE_CXX)
     add_executable(${PROJECT_NAME}_cpp test_package.cpp)
     target_link_libraries(${PROJECT_NAME}_cpp ${CONAN_LIBS})
-    set_property(TARGET ${PROJECT_NAME}_cpp PROPERTY LINKER_LANGUAGE CXX)
-endif()
\ No newline at end of file
+endif()
diff --git a/recipes/gmp/all/test_package/test_package.c b/recipes/gmp/all/test_package/test_package.c
--- a/recipes/gmp/all/test_package/test_package.c
+++ b/recipes/gmp/all/test_package/test_package.c
@@ -1,10 +1,25 @@
-#include <stdlib.h>
 #include <gmp.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
 int main (void) {
+    mpz_t a,b,c;
+    mpz_init_set_str(a, "1234", 10);
+    mpz_init_set_str(b, "4321", 10);
+    mpz_init(c);
+
+    mpz_add(c, a, b);
+
+    char *a_str = mpz_get_str(NULL, 10, a);
+    char *b_str = mpz_get_str(NULL, 10, b);
+    char *c_str = mpz_get_str(NULL, 10, c);
+
+    printf("%s + %s = %s\n", a_str, b_str, c_str);
 
-  mpz_t a,b,c;
-  mpz_inits(a,b,c,NULL);
+    free(a_str);
+    free(b_str);
+    free(c_str);
 
-  mpz_set_str(a, "1234", 10);
-  return EXIT_SUCCESS;
+    return EXIT_SUCCESS;
 }
diff --git a/recipes/gmp/all/test_package/test_package.cpp b/recipes/gmp/all/test_package/test_package.cpp
--- a/recipes/gmp/all/test_package/test_package.cpp
+++ b/recipes/gmp/all/test_package/test_package.cpp
@@ -1,12 +1,14 @@
-#include <cstdlib>
-#include <gmp.h>
+#include <gmpxx.h>
 
+#include <cstdlib>
+#include <iostream>
 
 int main (void) {
+    mpz_class a("1234");
+    mpz_class b("4321");
 
-  mpz_t a,b,c;
-  mpz_inits(a,b,c,NULL);
+    mpz_class c = a + b;
+    std::cout << a << " + " << b << " = " << c << "\n";
 
-  mpz_set_str(a, "1234", 10);
-  return EXIT_SUCCESS;
+    return EXIT_SUCCESS;
 }