Skip to content

Commit

Permalink
openmp: test package_info() output via PkgConfigDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Jul 17, 2024
1 parent 10c5a5a commit 50c2c88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions recipes/openmp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 6 additions & 2 deletions recipes/openmp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")

0 comments on commit 50c2c88

Please sign in to comment.