Skip to content

Commit

Permalink
conan v2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm committed Dec 26, 2022
1 parent c6eeeba commit 842dd91
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 471 deletions.
16 changes: 0 additions & 16 deletions recipes/opencv/4.x/CMakeLists.txt

This file was deleted.

66 changes: 62 additions & 4 deletions recipes/opencv/4.x/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,66 @@ sources:
- url: "https://github.com/opencv/opencv_contrib/archive/4.1.2.tar.gz"
sha256: "0f6c3d30baa39e3e7611afb481ee86dea45dafb182cac87d570c95dccd83eb8b"
patches:
"4.5.5":
- patch_file: "patches/4.5.5-0001-find-openexr.patch"
patch_description: "Robust discovery & injection of OpenEXR"
patch_type: "conan"
- patch_file: "patches/4.5.0-0002-find-ade.patch"
patch_description: "Robust discovery & injection of ade"
patch_type: "conan"
- patch_file: "patches/4.1.2-0003-find-quirc.patch"
patch_description: "Robust discovery & injection of quirc"
patch_type: "conan"
"4.5.3":
- patch_file: "patches/4.5.3-0001-find-openexr.patch"
patch_description: "Robust discovery & injection of OpenEXR"
patch_type: "conan"
- patch_file: "patches/4.5.0-0002-find-ade.patch"
patch_description: "Robust discovery & injection of ade"
patch_type: "conan"
- patch_file: "patches/4.1.2-0003-find-quirc.patch"
patch_description: "Robust discovery & injection of quirc"
patch_type: "conan"
"4.5.2":
- patch_file: "patches/4.1.2-0001-find-openexr.patch"
patch_description: "Robust discovery & injection of OpenEXR"
patch_type: "conan"
- patch_file: "patches/4.5.0-0002-find-ade.patch"
patch_description: "Robust discovery & injection of ade"
patch_type: "conan"
- patch_file: "patches/4.1.2-0003-find-quirc.patch"
patch_description: "Robust discovery & injection of quirc"
patch_type: "conan"
"4.5.1":
- patch_file: "patches/4.1.2-0001-find-openexr.patch"
patch_description: "Robust discovery & injection of OpenEXR"
patch_type: "conan"
- patch_file: "patches/4.5.0-0002-find-ade.patch"
patch_description: "Robust discovery & injection of ade"
patch_type: "conan"
- patch_file: "patches/4.1.2-0003-find-quirc.patch"
patch_description: "Robust discovery & injection of quirc"
patch_type: "conan"
"4.5.0":
- patch_file: "patches/4.1.2-0001-find-openexr.patch"
patch_description: "Robust discovery & injection of OpenEXR"
patch_type: "conan"
- patch_file: "patches/4.5.0-0002-find-ade.patch"
patch_description: "Robust discovery & injection of ade"
patch_type: "conan"
- patch_file: "patches/4.1.2-0003-find-quirc.patch"
patch_description: "Robust discovery & injection of quirc"
patch_type: "conan"
"4.1.2":
- patch_file: "patches/0001-jasper.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-openexr.patch"
base_path: "source_subfolder"
- patch_file: "patches/4.1.2-0001-find-openexr.patch"
patch_description: "Robust discovery & injection of OpenEXR"
patch_type: "conan"
- patch_file: "patches/4.1.2-0002-find-ade.patch"
patch_description: "Robust discovery & injection of ade"
patch_type: "conan"
- patch_file: "patches/4.1.2-0003-find-quirc.patch"
patch_description: "Robust discovery & injection of quirc"
patch_type: "conan"
- patch_file: "patches/4.1.2-0004-jasper.patch"
patch_description: "Compatibility with recent jasper versions"
patch_type: "portability"
523 changes: 243 additions & 280 deletions recipes/opencv/4.x/conanfile.py

Large diffs are not rendered by default.

143 changes: 0 additions & 143 deletions recipes/opencv/4.x/patches/0002-openexr.patch

This file was deleted.

18 changes: 18 additions & 0 deletions recipes/opencv/4.x/patches/4.1.2-0001-find-openexr.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- a/cmake/OpenCVFindOpenEXR.cmake
+++ b/cmake/OpenCVFindOpenEXR.cmake
@@ -9,6 +9,15 @@
# OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR.
#

+find_package(OpenEXR REQUIRED)
+if(TARGET OpenEXR::OpenEXR)
+ set(OPENEXR_LIBRARIES OpenEXR::OpenEXR)
+else()
+ set(OPENEXR_LIBRARIES openexr::openexr)
+endif()
+set(OPENEXR_FOUND TRUE)
+set(OPENEXR_VERSION ${OpenEXR_VERSION})
+return()
SET(OPENEXR_LIBRARIES "")
SET(OPENEXR_LIBSEARCH_SUFFIXES "")
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH)
11 changes: 11 additions & 0 deletions recipes/opencv/4.x/patches/4.1.2-0002-find-ade.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/modules/gapi/cmake/init.cmake
+++ b/modules/gapi/cmake/init.cmake
@@ -4,7 +4,7 @@ if(NOT WITH_ADE)
return()
endif()

-if (ade_DIR)
+if (1)
# if ade_DIR is set, use ADE-supplied CMake script
# to set up variables to the prebuilt ADE
find_package(ade 0.1.0)
8 changes: 8 additions & 0 deletions recipes/opencv/4.x/patches/4.1.2-0003-find-quirc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- a/modules/objdetect/CMakeLists.txt
+++ b/modules/objdetect/CMakeLists.txt
@@ -5,3 +5,2 @@ if(HAVE_QUIRC)
- get_property(QUIRC_INCLUDE GLOBAL PROPERTY QUIRC_INCLUDE_DIR)
- ocv_include_directories(${QUIRC_INCLUDE})
- ocv_target_link_libraries(${the_module} quirc)
+ find_package(quirc REQUIRED CONFIG)
+ ocv_target_link_libraries(${the_module} quirc::quirc)
11 changes: 11 additions & 0 deletions recipes/opencv/4.x/patches/4.5.0-0002-find-ade.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/modules/gapi/cmake/init.cmake
+++ b/modules/gapi/cmake/init.cmake
@@ -7,7 +7,7 @@ if(NOT WITH_ADE)
return()
endif()

-if(ade_DIR)
+if(1)
# if ade_DIR is set, use ADE-supplied CMake script
# to set up variables to the prebuilt ADE
find_package(ade 0.1.0)
23 changes: 23 additions & 0 deletions recipes/opencv/4.x/patches/4.5.3-0001-find-openexr.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- a/cmake/OpenCVFindOpenEXR.cmake
+++ b/cmake/OpenCVFindOpenEXR.cmake
@@ -9,13 +9,15 @@
# OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR.
#

-find_package(OpenEXR 3.0 CONFIG QUIET)
+find_package(OpenEXR REQUIRED)
if(TARGET OpenEXR::OpenEXR)
- SET(OPENEXR_FOUND TRUE)
- SET(OPENEXR_LIBRARIES OpenEXR::OpenEXR)
- SET(OPENEXR_VERSION ${OpenEXR_VERSION})
- return()
+ set(OPENEXR_LIBRARIES OpenEXR::OpenEXR)
+else()
+ set(OPENEXR_LIBRARIES openexr::openexr)
endif()
+set(OPENEXR_FOUND TRUE)
+set(OPENEXR_VERSION ${OpenEXR_VERSION})
+return()

SET(OPENEXR_LIBRARIES "")
SET(OPENEXR_LIBSEARCH_SUFFIXES "")
32 changes: 32 additions & 0 deletions recipes/opencv/4.x/patches/4.5.5-0001-find-openexr.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--- a/cmake/OpenCVFindOpenEXR.cmake
+++ b/cmake/OpenCVFindOpenEXR.cmake
@@ -9,21 +9,15 @@
# OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR.
#

-if(NOT OPENCV_SKIP_OPENEXR_FIND_PACKAGE)
- find_package(OpenEXR 3 QUIET)
- #ocv_cmake_dump_vars(EXR)
- if(OpenEXR_FOUND)
- if(TARGET OpenEXR::OpenEXR) # OpenEXR 3+
- set(OPENEXR_LIBRARIES OpenEXR::OpenEXR)
- set(OPENEXR_INCLUDE_PATHS "")
- set(OPENEXR_VERSION "${OpenEXR_VERSION}")
- set(OPENEXR_FOUND 1)
- return()
- else()
- message(STATUS "Unsupported find_package(OpenEXR) - missing OpenEXR::OpenEXR target (version ${OpenEXR_VERSION})")
- endif()
- endif()
+find_package(OpenEXR REQUIRED)
+if(TARGET OpenEXR::OpenEXR)
+ set(OPENEXR_LIBRARIES OpenEXR::OpenEXR)
+else()
+ set(OPENEXR_LIBRARIES openexr::openexr)
endif()
+set(OPENEXR_FOUND TRUE)
+set(OPENEXR_VERSION ${OpenEXR_VERSION})
+return()

SET(OPENEXR_LIBRARIES "")
SET(OPENEXR_LIBSEARCH_SUFFIXES "")
35 changes: 15 additions & 20 deletions recipes/opencv/4.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

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

find_package(OpenCV REQUIRED imgcodecs highgui objdetect CONFIG)
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

option(built_with_ade "Enabled if opencv is built with ade" OFF)
if(built_with_ade)
add_definitions(-DBUILT_WITH_ADE)
endif()

option(built_with_ffmpeg "Enabled if opencv is built with ffmpeg" OFF)
if(built_with_ffmpeg)
add_definitions(-DBUILT_WITH_FFMPEG)
endif()

option(built_contrib_sfm "Enabled if opencv is built contrib sfm" OFF)
if(built_contrib_sfm)
add_definitions(-DBUILT_CONTRIB_SFM)
endif()

find_package(OpenCV REQUIRED imgcodecs highgui objdetect CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} PRIVATE
opencv_imgcodecs
opencv_highgui
opencv_objdetect
$<TARGET_NAME_IF_EXISTS:opencv_gapi>
$<TARGET_NAME_IF_EXISTS:opencv_videoio>
$<TARGET_NAME_IF_EXISTS:opencv_sfm>
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
if(built_with_ade)
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILT_WITH_ADE)
endif()
if(built_with_ffmpeg)
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILT_WITH_FFMPEG)
endif()
if(built_contrib_sfm)
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILT_CONTRIB_SFM)
endif()
Loading

0 comments on commit 842dd91

Please sign in to comment.