Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding new package cvplot #8167

Merged
merged 8 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/cvplot/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.2.2":
url: "https://github.com/Profactor/cv-plot/archive/refs/tags/v1.2.2.tar.gz"
sha256: "a7dbc80a8ec13fa2cfdc4f1389a1eb0cb83b56f021c64214d733812d3e301bc5"
36 changes: 36 additions & 0 deletions recipes/cvplot/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from conans import ConanFile, tools
import os

required_conan_version = ">=1.43.0"


class CvPlotConan(ConanFile):
name = "cvplot"
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"
generators = "cmake"
wpalfi marked this conversation as resolved.
Show resolved Hide resolved
requires = "opencv/4.5.3"
no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"

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

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()

def package_info(self):
self.cpp_info.defines.append("CVPLOT_HEADER_ONLY")
wpalfi marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.set_property("cmake_find_mode", "both")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not able to find any modules being installed 🤔

Suggested change
self.cpp_info.set_property("cmake_find_mode", "both")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about that. I thought both means, that we support both find_package(CvPlot CONFIG) and find_package(CvPlot MODULE)?

I tried the MODULE version. Conan creates a Findcvplot.cmake then but cmake does not find opencv:

-- Found cvplot: 1.2.2 (found version "1.2.2")
-- Conan: Target declared 'cvplot::cvplot'
CMake Error at /usr/share/cmake-3.16/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  No "Findopencv.cmake" found in CMAKE_MODULE_PATH.
Call Stack (most recent call first):
  build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f/FindCvPlot.cmake:25 (find_dependency)
  CMakeLists.txt:7 (find_package) 

So I guess we should stick to the default config mode?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have to add

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That solves the CvPlot spelling, but I still dont know how to consume the FindCvPlot.cmake. Always getting No "Findopencv.cmake".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, Conan generates OpenCV.cmake not opencv.cmake. Do you have a log? The CI is working for the test package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some consumers may use find_package(cvplot CONFIG) and some may use find_package(cvplot MODULE), right? is there any reason not to support both use-cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SSE4 as I said above:

  • find_package(cvplot MODULE) already works with generators = "cmake", "cmake_find_package" and does not need self.cpp_info.set_property("cmake_find_mode", "both")
  • The only problem is with generators = "cmake", "CMakeDeps" (No "Findopencv.cmake" found)

Copy link
Contributor

@prince-chrismc prince-chrismc Jan 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the CMake docs https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules find_package(cvplot MODULE) does not exist ... to my knowledge. I do not expect it to work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this list built-in CMake modules only, but someone can use the custom Find module in his own project, right? I've seen it in a lot of OSS projects in the wild, it's pretty common practice

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly theres been a lot of misuse... downstream project can write their own (which is fairly common) then this setting makes sense

https://cmake.org/cmake/help/latest/command/find_package.html#id4

The file CMake searches for in module mode should not be provided by the package itself.


Looking in the github repo I dont see any custom files... but it's not easy to search all projects

self.cpp_info.names["cmake_find_package"] = "CvPlot"
self.cpp_info.names["cmake_find_package_multi"] = "CvPlot"
12 changes: 12 additions & 0 deletions recipes/cvplot/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.1)
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)
target_link_libraries(${PROJECT_NAME} CvPlot::CvPlot)

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
17 changes: 17 additions & 0 deletions recipes/cvplot/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


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

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)
9 changes: 9 additions & 0 deletions recipes/cvplot/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <CvPlot/cvplot.h>

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);
return 0;
}
3 changes: 3 additions & 0 deletions recipes/cvplot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.2.2":
folder: all