Skip to content

Commit

Permalink
(#16678) openvc: 4.x modernize more for conan v2
Browse files Browse the repository at this point in the history
* openvc: 4.x bump libwebp

* v2: disable ffmpeg

* chore: disable ffmpeg more

* chore: use `self.dependencies["gtk"].options.version`

* fixup: protobuf symbols are exposed

* add dnn componment when option is enabled

* opencv: restore ffmpeg and fixes for conan 2.0

---------

Co-authored-by: Luis Caro Campos <3535649+jcar87@users.noreply.github.com>
  • Loading branch information
Chris Mc and jcar87 authored May 8, 2023
1 parent 2811137 commit 227d682
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
16 changes: 8 additions & 8 deletions recipes/opencv/4.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def requirements(self):
if self.options.with_ipp == "intel-ipp":
self.requires("intel-ipp/2020")
if self.options.with_webp:
self.requires("libwebp/1.2.4")
self.requires("libwebp/1.3.0")
if self.options.get_safe("contrib_freetype"):
self.requires("freetype/2.12.1")
self.requires("harfbuzz/6.0.0")
Expand All @@ -219,7 +219,8 @@ def requirements(self):
if self.options.get_safe("with_gtk"):
self.requires("gtk/system")
if self.options.dnn:
self.requires(f"protobuf/{self._protobuf_version}")
# Symbols are exposed https://github.com/conan-io/conan-center-index/pull/16678#issuecomment-1507811867
self.requires(f"protobuf/{self._protobuf_version}", transitive_libs=True)
if self.options.with_ade:
self.requires("ade/0.1.2a")

Expand All @@ -244,8 +245,7 @@ def build_requirements(self):
self.tool_requires(f"protobuf/{self._protobuf_version}")

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

get(self, **self.conan_data["sources"][self.version][1],
destination=self._contrib_folder, strip_root=True)
Expand Down Expand Up @@ -371,9 +371,9 @@ def generate(self):
tc.variables["OPENCV_FFMPEG_USE_FIND_PACKAGE"] = "ffmpeg"
tc.variables["OPENCV_INSTALL_FFMPEG_DOWNLOAD_SCRIPT"] = False
tc.variables["FFMPEG_LIBRARIES"] = "ffmpeg::avcodec;ffmpeg::avformat;ffmpeg::avutil;ffmpeg::swscale"
for component in ["avcodec", "avformat", "avutil", "swscale", "avresample"]:
# TODO: use self.dependencies once https://github.com/conan-io/conan/issues/12728 fixed
ffmpeg_component_version = self.deps_cpp_info["ffmpeg"].components[component].version
ffmpeg_cpp_info = self.dependencies["ffmpeg"].cpp_info
for component in ["avcodec", "avformat", "avutil", "swscale"]:
ffmpeg_component_version = ffmpeg_cpp_info.components[component].get_property("component_version")
tc.variables[f"FFMPEG_lib{component}_VERSION"] = ffmpeg_component_version

tc.variables["WITH_GSTREAMER"] = False
Expand Down Expand Up @@ -540,7 +540,7 @@ def _is_gtk_version2(self):
return False
gtk_version = self.dependencies["gtk"].ref.version
if gtk_version == "system":
return self.options["gtk"].version == 2
return self.dependencies["gtk"].options.version == 2
else:
return Version(gtk_version) < "3.0.0"

Expand Down
4 changes: 4 additions & 0 deletions recipes/opencv/4.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

option(built_dnn "Enabled if opencv is built dnn" OFF)
option(built_with_ade "Enabled if opencv is built with ade" OFF)
option(built_with_ffmpeg "Enabled if opencv is built with ffmpeg" OFF)
option(built_contrib_sfm "Enabled if opencv is built contrib sfm" OFF)
Expand All @@ -17,6 +18,9 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
$<TARGET_NAME_IF_EXISTS:opencv_sfm>
)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
if(built_dnn)
target_link_libraries(${PROJECT_NAME} PRIVATE opencv_dnn)
endif()
if(built_with_ade)
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILT_WITH_ADE)
endif()
Expand Down
1 change: 1 addition & 0 deletions recipes/opencv/4.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def requirements(self):

def generate(self):
tc = CMakeToolchain(self)
tc.variables["built_dnn"] = self.dependencies["opencv"].options.dnn
tc.variables["built_with_ade"] = self.dependencies["opencv"].options.with_ade
tc.variables["built_with_ffmpeg"] = self.dependencies["opencv"].options.with_ffmpeg
tc.variables["built_contrib_sfm"] = self.dependencies["opencv"].options.contrib and self.dependencies["opencv"].options.contrib_sfm
Expand Down
1 change: 1 addition & 0 deletions recipes/opencv/4.x/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TestPackageConan(ConanFile):

def build(self):
cmake = CMake(self)
cmake.definitions["built_dnn"] = self.options["opencv"].dnn
cmake.definitions["built_with_ade"] = self.options["opencv"].with_ade
cmake.definitions["built_with_ffmpeg"] = self.options["opencv"].with_ffmpeg
cmake.definitions["built_contrib_sfm"] = self.options["opencv"].contrib and self.options["opencv"].contrib_sfm
Expand Down

0 comments on commit 227d682

Please sign in to comment.