Skip to content

Commit

Permalink
coin-cbc: disable PkgConfigDeps generator in tests
Browse files Browse the repository at this point in the history
Transitive dependency handling is incredibly broken with it, for some reason.
  • Loading branch information
valgur committed Nov 23, 2023
1 parent 456005d commit f43eadc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
14 changes: 5 additions & 9 deletions recipes/coin-cbc/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ def layout(self):
def requirements(self):
self.requires("coin-utils/2.11.9")
self.requires("coin-osi/0.108.7")
self.requires("coin-clp/1.17.7")
self.requires("coin-clp/1.17.7", transitive_headers=True, transitive_libs=True)
self.requires("coin-cgl/0.60.7")
if is_msvc(self) and self.options.parallel:
self.requires("pthreads4w/3.0.0")
# FIXME: these should probably be marked as transitive in coin-utils
# https://c3i.jfrog.io/c3i/misc/logs/pr/18864/6-linux-gcc/coin-cbc/2.10.5/967138bd48a5d716a011a2a51f6affbb66e8ab9c-test.txt
self.requires("bzip2/1.0.8", transitive_headers=True, transitive_libs=True)
self.requires("zlib/[>=1.2.11 <2]", transitive_headers=True, transitive_libs=True)

def validate(self):
# FIXME: This issue likely comes from very old autotools versions used to produce configure.
Expand Down Expand Up @@ -160,9 +156,10 @@ def package_info(self):
self.cpp_info.components["libcbc"].libs = ["CbcSolver", "Cbc"]
self.cpp_info.components["libcbc"].includedirs.append(os.path.join("include", "coin"))
self.cpp_info.components["libcbc"].requires = [
"coin-clp::osi-clp", "coin-utils::coin-utils", "coin-osi::coin-osi", "coin-cgl::coin-cgl",
# FIXME: move to coin-utils
"zlib::zlib", "bzip2::bzip2"
"coin-clp::osi-clp",
"coin-utils::coin-utils",
"coin-osi::coin-osi",
"coin-cgl::coin-cgl",
]
self.cpp_info.components["libcbc"].set_property("pkg_config_name", "cbc")
if self.settings.os in ["Linux", "FreeBSD"] and self.options.parallel:
Expand All @@ -176,5 +173,4 @@ def package_info(self):

# TODO: remove in conan v2
bin_path = os.path.join(self.package_folder, "bin")
self.output.info(f"Appending PATH environment variable: {bin_path}")
self.env_info.PATH.append(bin_path)
11 changes: 7 additions & 4 deletions recipes/coin-cbc/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

include(FindPkgConfig)
pkg_check_modules(OsiCbc REQUIRED IMPORTED_TARGET osi-cbc)
#include(FindPkgConfig)
#pkg_check_modules(OsiCbc REQUIRED IMPORTED_TARGET osi-cbc)
#add_executable(${PROJECT_NAME}_pkgconfig test_package.cpp)
#target_link_libraries(${PROJECT_NAME}_pkgconfig PRIVATE PkgConfig::OsiCbc)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::OsiCbc)
find_package(coin-cbc CONFIG REQUIRED)
add_executable(${PROJECT_NAME}_cmake test_package.cpp)
target_link_libraries(${PROJECT_NAME}_cmake PRIVATE coin-cbc::coin-cbc)
6 changes: 4 additions & 2 deletions recipes/coin-cbc/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "PkgConfigDeps", "CMakeToolchain", "VirtualRunEnv"
generators = "PkgConfigDeps", "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
Expand All @@ -26,5 +26,7 @@ def build(self):

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
# bin_path = os.path.join(self.cpp.build.bindir, "test_package_pkgconfig")
# self.run(bin_path, env="conanrun")
bin_path = os.path.join(self.cpp.build.bindir, "test_package_cmake")
self.run(bin_path, env="conanrun")
6 changes: 4 additions & 2 deletions recipes/coin-cbc/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "pkg_config"
generators = "cmake", "cmake_find_package_multi", "pkg_config"

def build_requirements(self):
self.build_requires("pkgconf/2.0.3")
Expand All @@ -16,5 +16,7 @@ def build(self):

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
# bin_path = os.path.join("bin", "test_package_pkgconfig")
# self.run(bin_path, run_environment=True)
bin_path = os.path.join("bin", "test_package_cmake")
self.run(bin_path, run_environment=True)

0 comments on commit f43eadc

Please sign in to comment.