Skip to content

Commit

Permalink
(conan-io#18094) cvplot: migrate to Conan v2
Browse files Browse the repository at this point in the history
* cvplot: migrate to Conan v2

* cvplot: rm unnecessary cmake_* properties

---------

Co-authored-by: Carlos Zoido <[email protected]>
  • Loading branch information
valgur and czoido authored Jul 3, 2023
1 parent f522f84 commit 7f46775
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 29 deletions.
58 changes: 41 additions & 17 deletions recipes/cvplot/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,59 @@
from conans import ConanFile, tools
import os

required_conan_version = ">=1.43.0"
from conan import ConanFile
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout

required_conan_version = ">=1.52.0"


class CvPlotConan(ConanFile):
name = "cvplot"
description = "fast modular opencv plotting library"
description = "Fast modular OpenCV plotting library"
license = "MIT"
topics = ("plot", "opencv", "diagram", "plotting")
homepage = "https://github.com/Profactor/cv-plot"
url = "https://github.com/conan-io/conan-center-index"
requires = "opencv/4.5.3"
homepage = "https://github.com/Profactor/cv-plot"
topics = ("plot", "opencv", "diagram", "plotting", "header-only")

package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"
def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("opencv/4.5.5")

def package_id(self):
self.info.clear()

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "CvPlot", "inc"))

def package_id(self):
self.info.header_only()

copy(
self,
pattern="LICENSE",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder,
)
copy(
self,
pattern="*",
dst=os.path.join(self.package_folder, "include"),
src=os.path.join(self.source_folder, "CvPlot", "inc"),
)

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

self.cpp_info.set_property("cmake_file_name", "CvPlot")
self.cpp_info.set_property("cmake_target_name", "CvPlot::CvPlot")
self.cpp_info.set_property("cmake_find_mode", "both")

self.cpp_info.defines.append("CVPLOT_HEADER_ONLY")
self.cpp_info.set_property("cmake_find_mode", "both")

self.cpp_info.names["cmake_find_package"] = "CvPlot"
self.cpp_info.names["cmake_find_package_multi"] = "CvPlot"
5 changes: 1 addition & 4 deletions recipes/cvplot/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.15)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(CvPlot CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.cpp)
Expand Down
21 changes: 15 additions & 6 deletions recipes/cvplot/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


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

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
4 changes: 2 additions & 2 deletions recipes/cvplot/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using namespace CvPlot;

int main() {
Axes axes = plot(std::vector<double>{ 3, 3, 4, 6, 4, 3 }, "-o");
cv::Mat mat = axes.render(400, 600);
Axes axes = plot(std::vector<double>{3, 3, 4, 6, 4, 3}, "-o");
cv::Mat mat = axes.render(400, 600);
return 0;
}

0 comments on commit 7f46775

Please sign in to comment.