From 50c2c8850a04f1effe04edf3051da5b5547ee3b3 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 17 Jul 2024 19:04:05 +0300 Subject: [PATCH] openmp: test package_info() output via PkgConfigDeps --- recipes/openmp/all/test_package/CMakeLists.txt | 7 +++++++ recipes/openmp/all/test_package/conanfile.py | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/recipes/openmp/all/test_package/CMakeLists.txt b/recipes/openmp/all/test_package/CMakeLists.txt index 4ec635c0c531d..9c91ac49f68da 100644 --- a/recipes/openmp/all/test_package/CMakeLists.txt +++ b/recipes/openmp/all/test_package/CMakeLists.txt @@ -24,3 +24,10 @@ target_link_libraries(test_package_cxx OpenMP::OpenMP_CXX) add_executable(test_package_c test_package.c) target_link_libraries(test_package_c OpenMP::OpenMP_C) + +# Using PkgConfigDeps output to test the configuration exported by package_info(). +# This is not a recommended or conventional way to use OpenMP. +find_package(PkgConfig REQUIRED) +pkg_check_modules(openmp REQUIRED IMPORTED_TARGET openmp) +add_executable(test_package_pkgconfig test_package.c) +target_link_libraries(test_package_pkgconfig PkgConfig::openmp) diff --git a/recipes/openmp/all/test_package/conanfile.py b/recipes/openmp/all/test_package/conanfile.py index 6dfdd10386483..dc941c2b3f789 100644 --- a/recipes/openmp/all/test_package/conanfile.py +++ b/recipes/openmp/all/test_package/conanfile.py @@ -7,12 +7,16 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + generators = "CMakeDeps", "CMakeToolchain", "PkgConfigDeps", "VirtualBuildEnv", "VirtualRunEnv" test_type = "explicit" def requirements(self): self.requires(self.tested_reference_str) + def build_requirements(self): + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/2.2.0") + def layout(self): cmake_layout(self) @@ -33,6 +37,6 @@ def build(self): def test(self): if can_run(self): - for executable in ["test_package_cxx", "test_package_c"]: + for executable in ["test_package_cxx", "test_package_c", "test_package_pkgconfig"]: bin_path = os.path.join(self.cpp.build.bindir, executable) self.run(bin_path, env="conanrun")