Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Add option with_highgui to be able to build without gui dependencies #68

Open
wants to merge 1 commit into
base: release/4.3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class OpenCVConan(ConanFile):
"ffmpeg": [True, False],
"lapack": [True, False],
"parallel": ["tbb", "openmp", None],
"quirc": [True, False]}
"quirc": [True, False],
"with_highgui": [True, False]}
default_options = {"shared": False,
"fPIC": True,
"contrib": False,
Expand All @@ -67,7 +68,8 @@ class OpenCVConan(ConanFile):
"ffmpeg": False,
"lapack": False,
"parallel": None,
"quirc": True}
"quirc": True,
"with_highgui": True}
exports_sources = ["CMakeLists.txt", "patches/*.patch"]
exports = "LICENSE"
generators = "cmake"
Expand Down Expand Up @@ -382,6 +384,9 @@ def _configure_cmake(self):
# quirc
cmake.definitions['WITH_QUIRC'] = self.options.quirc

# HighGUI
cmake.definitions['BUILD_opencv_highgui'] = self.options.with_highgui

# TIFF
cmake.definitions['BUILD_TIFF'] = False
cmake.definitions['WITH_TIFF'] = self.options.tiff
Expand Down Expand Up @@ -514,6 +519,9 @@ def package_info(self):
# https://github.com/opencv/opencv/blob/4.0.1/modules/gapi/cmake/DownloadADE.cmake#L2
opencv_libs.append("gapi")

if not self.options.with_highgui:
opencv_libs.remove("highgui")

if self.options.contrib:
opencv_libs = [
"aruco",
Expand Down
6 changes: 4 additions & 2 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
CONAN_BASIC_SETUP()

ADD_EXECUTABLE(lena lena.cpp)
TARGET_LINK_LIBRARIES(lena ${CONAN_LIBS})
if(TEST_GUI)
ADD_EXECUTABLE(lena lena.cpp)
TARGET_LINK_LIBRARIES(lena ${CONAN_LIBS})
endif()

ADD_EXECUTABLE(load-image load-image.cpp)
TARGET_LINK_LIBRARIES(load-image ${CONAN_LIBS})
Expand Down
6 changes: 4 additions & 2 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TestPackageConan(ConanFile):

def build(self):
cmake = CMake(self)
cmake.definitions['TEST_GUI'] = self.options["opencv"].with_highgui
cmake.configure()
cmake.build()

Expand All @@ -26,11 +27,12 @@ def test(self):
img_path = os.path.join(self.source_folder, "lena.jpg")
shutil.copy(img_path, 'bin')
with tools.chdir('bin'):
self.run('lena.exe' if self.settings.os == 'Windows' else './lena', run_environment=True)
if self.options["opencv"].with_highgui:
self.run('lena.exe' if self.settings.os == 'Windows' else './lena', run_environment=True)
test_images = []
if self.options["opencv"].jpeg:
test_images.append('lena.jpg')
if self.options["opencv"].libtiff != False:
if self.options["opencv"].tiff != False:
test_images.append('normal.tiff')
if self.options["libtiff"].lzma != False:
test_images.append('lzma.tiff')
Expand Down