Skip to content

Commit

Permalink
Ensure working test_package conan v1
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimono committed Jul 6, 2023
1 parent 0a8e5e9 commit cbef89f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-conan-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
-s compiler.version=${{ matrix.compiler_version }} \
-s compiler.cppstd=${{ env.cppstd }} \
-pr:b=${{ matrix.profile }} -pr:h=${{ matrix.profile }} \
- o ${{ env.package_name }}/*:shared=${{ matrix.shared }} \
-o ${{ env.package_name }}/*:shared=${{ matrix.shared }} \
-b missing -b outdated -b ${{ env.package_name }}* \
. ${{ env.PKG_REFERENCE }}
- name: Conan upload
Expand Down
20 changes: 12 additions & 8 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from os import path
from conan import ConanFile
from conan import ConanFile, conan_version
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain

from conan.tools.scm import Version

class MathglTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
Expand All @@ -11,17 +11,20 @@ class MathglTestConan(ConanFile):

def requirements(self):
self.requires(self.tested_reference_str)
self.requires("qt/5.15.9")
self.requires("opengl/system")

def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["WITH_QT"] = self.dependencies["mathgl"].options.qt5
tc.variables["WITH_OPENGL"] = self.dependencies["mathgl"].options.opengl and \
not self.dependencies["mathgl"].options.shared and self.settings.os == "Windows"
if Version(conan_version).major < 2:
tc.variables["WITH_QT"] = self.options["mathgl"].qt5
tc.variables["WITH_OPENGL"] = self.options["mathgl"].opengl and \
not self.options["mathgl"].shared and self.settings.os == "Windows"
else:
tc.variables["WITH_QT"] = self.dependencies["mathgl"].options.qt5
tc.variables["WITH_OPENGL"] = self.dependencies["mathgl"].options.opengl and \
not self.dependencies["mathgl"].options.shared and self.settings.os == "Windows"
tc.generate()

def build(self):
Expand All @@ -34,7 +37,8 @@ def test(self):
bin_path = path.join(self.cpp.build.bindirs[0], "example")
self.run(bin_path, env="conanrun")

if self.dependencies["mathgl"].options.qt5:
if (Version(conan_version).major < 2 and self.options["mathgl"].qt5) or \
(Version(conan_version).major > 1 and self.dependencies["mathgl"].options.qt5):
bin_path = path.join(self.cpp.build.bindirs[0], "qt_example")

self.run(bin_path + " -platform offscreen", env="conanrun")

0 comments on commit cbef89f

Please sign in to comment.