Repository: conan-io/conan-center-index

Issue:
[package] gstreamer/1.x: WARNING: pkgconfig variable 'libexecdir' not defined for dependency gstreamer-1.0.
libexecdir pkgconfig variable is missing. therefore giving me a warning when I use this to build `gst-libav`. Might not be an issue for me but filing the bug report in case someone wants to fix it.


Discussion:
If the warning is fatal, this can be fixed by adding `self.cpp_info.set_property("pkg_config_custom_content", ...)` in `package_info` of gstreamer.
something to consider after #7454
/cc @sh0

Resolving patch:
diff --git a/recipes/gstreamer/all/conanfile.py b/recipes/gstreamer/all/conanfile.py
--- a/recipes/gstreamer/all/conanfile.py
+++ b/recipes/gstreamer/all/conanfile.py
@@ -35,7 +35,7 @@ def _build_subfolder(self):
         return "build_subfolder"
 
     def requirements(self):
-        self.requires("glib/2.69.0")
+        self.requires("glib/2.70.0")
 
     @property
     def _is_msvc(self):
@@ -53,13 +53,13 @@ def config_options(self):
 
     def build_requirements(self):
         self.build_requires("meson/0.56.2")
-        self.build_requires("pkgconf/1.7.3")
+        self.build_requires("pkgconf/1.7.4")
         if self.options.with_introspection:
-            self.build_requires("gobject-introspection/1.68.0")
+            self.build_requires("gobject-introspection/1.69.0")
         if self.settings.os == 'Windows':
-            self.build_requires("winflexbison/2.5.22")
+            self.build_requires("winflexbison/2.5.24")
         else:
-            self.build_requires("bison/3.7.1")
+            self.build_requires("bison/3.7.6")
             self.build_requires("flex/2.6.4")
 
     def source(self):
@@ -117,6 +117,19 @@ def package(self):
     def package_info(self):
         gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0")
 
+        pkgconfig_variables = {
+            "exec_prefix": "${prefix}",
+            "toolsdir": "${exec_prefix}/bin",
+            "pluginsdir": "${libdir}/gstreamer-1.0",
+            "datarootdir": "${prefix}/share",
+            "datadir": "${datarootdir}",
+            "girdir": "${datadir}/gir-1.0",
+            "typelibdir": "${libdir}/girepository-1.0",
+            "libexecdir": "${prefix}/libexec",
+            "pluginscannerdir": "${libexecdir}/gstreamer-1.0",
+        }
+        pkgconfig_custom_content = "\n".join("{}={}".format(key, value) for key, value in pkgconfig_variables.items())
+
         self.cpp_info.components["gstreamer-1.0"].names["pkg_config"] = "gstreamer-1.0"
         self.cpp_info.components["gstreamer-1.0"].requires = ["glib::glib-2.0", "glib::gobject-2.0"]
         if not self.options.shared:
@@ -124,26 +137,37 @@ def package_info(self):
             self.cpp_info.components["gstreamer-1.0"].defines.append("GST_STATIC_COMPILATION")
         self.cpp_info.components["gstreamer-1.0"].libs = ["gstreamer-1.0"]
         self.cpp_info.components["gstreamer-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")]
+        if self.settings.os == "Linux":
+            self.cpp_info.components["gstreamer-1.0"].system_libs = ["m"]
+        self.cpp_info.components["gstreamer-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content)
                                        
         self.cpp_info.components["gstreamer-base-1.0"].names["pkg_config"] = "gstreamer-base-1.0"
         self.cpp_info.components["gstreamer-base-1.0"].requires = ["gstreamer-1.0"]
         self.cpp_info.components["gstreamer-base-1.0"].libs = ["gstbase-1.0"]
         self.cpp_info.components["gstreamer-base-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")]
+        self.cpp_info.components["gstreamer-base-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content)
                                        
         self.cpp_info.components["gstreamer-controller-1.0"].names["pkg_config"] = "gstreamer-controller-1.0"
         self.cpp_info.components["gstreamer-controller-1.0"].requires = ["gstreamer-1.0"]
         self.cpp_info.components["gstreamer-controller-1.0"].libs = ["gstcontroller-1.0"]
         self.cpp_info.components["gstreamer-controller-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")]
+        if self.settings.os == "Linux":
+            self.cpp_info.components["gstreamer-controller-1.0"].system_libs = ["m"]
+        self.cpp_info.components["gstreamer-controller-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content)
                                        
         self.cpp_info.components["gstreamer-net-1.0"].names["pkg_config"] = "gstreamer-net-1.0"
         self.cpp_info.components["gstreamer-net-1.0"].requires = ["gstreamer-1.0", "glib::gio-2.0"]
         self.cpp_info.components["gstreamer-net-1.0"].libs = ["gstnet-1.0"]
         self.cpp_info.components["gstreamer-net-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")]
+        self.cpp_info.components["gstreamer-net-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content)
                                        
         self.cpp_info.components["gstreamer-check-1.0"].names["pkg_config"] = "gstreamer-check-1.0"
         self.cpp_info.components["gstreamer-check-1.0"].requires = ["gstreamer-1.0"]
         self.cpp_info.components["gstreamer-check-1.0"].libs = ["gstcheck-1.0"]
         self.cpp_info.components["gstreamer-check-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")]
+        if self.settings.os == "Linux":
+            self.cpp_info.components["gstreamer-check-1.0"].system_libs = ["rt", "m"]
+        self.cpp_info.components["gstreamer-check-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content)
                                        
         # gstcoreelements and gstcoretracers are plugins which should be loaded dynamicaly, and not linked to directly
         if not self.options.shared:


Test patch:
diff --git a/recipes/gstreamer/all/test_package/CMakeLists.txt b/recipes/gstreamer/all/test_package/CMakeLists.txt
--- a/recipes/gstreamer/all/test_package/CMakeLists.txt
+++ b/recipes/gstreamer/all/test_package/CMakeLists.txt
@@ -1,8 +1,15 @@
 cmake_minimum_required(VERSION 3.1)
-project(test_package)
+project(test_package LANGUAGES C)
 
 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
-conan_basic_setup()
+conan_basic_setup(TARGETS)
 
-add_executable(${PROJECT_NAME} test_package.cpp)
-target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
+find_package(gstreamer REQUIRED CONFIG)
+
+add_executable(${PROJECT_NAME} test_package.c)
+target_link_libraries(${PROJECT_NAME}
+    gstreamer::gstreamer-1.0 gstreamer::gstreamer-base-1.0 gstreamer::gstreamer-controller-1.0
+    gstreamer::gstreamer-net-1.0 gstreamer::gstreamer-check-1.0)
+if (TARGET gstreamer::gstcoreelements)
+    target_link_libraries(${PROJECT_NAME} gstreamer::gstcoreelements)
+endif ()
diff --git a/recipes/gstreamer/all/test_package/conanfile.py b/recipes/gstreamer/all/test_package/conanfile.py
--- a/recipes/gstreamer/all/test_package/conanfile.py
+++ b/recipes/gstreamer/all/test_package/conanfile.py
@@ -4,7 +4,7 @@
 
 class TestPackageConan(ConanFile):
     settings = "os", "compiler", "build_type", "arch"
-    generators = "cmake"
+    generators = "cmake", "cmake_find_package_multi"
 
     def build(self):
         cmake = CMake(self)
@@ -12,6 +12,6 @@ def build(self):
         cmake.build()
 
     def test(self):
-        if not tools.cross_building(self.settings):
+        if not tools.cross_building(self):
             bin_path = os.path.join("bin", "test_package")
             self.run(bin_path, run_environment=True)
diff --git a/recipes/gstreamer/all/test_package/test_package.cpp b/recipes/gstreamer/all/test_package/test_package.c
similarity index 50%
rename from recipes/gstreamer/all/test_package/test_package.cpp
rename to recipes/gstreamer/all/test_package/test_package.c
--- a/recipes/gstreamer/all/test_package/test_package.cpp
+++ b/recipes/gstreamer/all/test_package/test_package.c
@@ -1,41 +1,35 @@
-#include <iostream>
+#include <stdlib.h>
+#include <stdio.h>
 #include <gst/gst.h>
 
 #ifdef GST_STATIC_COMPILATION
-
-extern "C"
-{
-    GST_PLUGIN_STATIC_DECLARE(coreelements);
-}
-
+GST_PLUGIN_STATIC_DECLARE(coreelements);
 #endif
 
 int main(int argc, char * argv[])
 {
     gst_init(&argc, &argv);
-    std::cout << "GStreamer version: " << gst_version_string() << std::endl;
+    printf("GStreamer version: %s\n", gst_version_string());
 
 #ifdef GST_STATIC_COMPILATION
-
     GST_PLUGIN_STATIC_REGISTER(coreelements);
-
 #endif
 
     GstElement * fakesink = gst_element_factory_make("fakesink", NULL);
     if (!fakesink) {
-        std::cerr << "failed to create fakesink element" << std::endl;
-        return -1;
+        printf("failed to create fakesink element\n");
+        return EXIT_FAILURE;
     } else {
-        std::cout << "fakesink has been created successfully" << std::endl;
+        printf("fakesink has been created successfully\n");
     }
     gst_object_unref(GST_OBJECT(fakesink));
     GstElement * fakesrc = gst_element_factory_make("fakesrc", NULL);
     if (!fakesrc) {
-        std::cerr << "failed to create fakesrc element" << std::endl;
-        return -1;
+        printf("failed to create fakesrc element\n");
+        return EXIT_FAILURE;
     } else {
-        std::cout << "fakesrc has been created successfully" << std::endl;
+        printf("fakesrc has been created successfully\n");
     }
     gst_object_unref(GST_OBJECT(fakesrc));
-    return 0;
+    return EXIT_SUCCESS;
 }