Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
2638abe1
Commit
2638abe1
authored
Dec 19, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7694 from sergiud:cmake-config-optional-components
parents
86bb5239
d71ec0cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
9 deletions
+42
-9
OpenCVConfig.cmake.in
cmake/templates/OpenCVConfig.cmake.in
+42
-9
No files found.
cmake/templates/OpenCVConfig.cmake.in
View file @
2638abe1
...
...
@@ -14,6 +14,10 @@
#
# find_package(OpenCV REQUIRED core videoio)
#
# You can also mark OpenCV components as optional:
# find_package(OpenCV REQUIRED core OPTIONAL_COMPONENTS viz)
#
# If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
#
# This file will define the following variables:
...
...
@@ -48,6 +52,21 @@ SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@)
SET(OpenCV_VERSION_TWEAK 0)
SET(OpenCV_VERSION_STATUS "@OPENCV_VERSION_STATUS@")
include(FindPackageHandleStandardArgs)
if(NOT CMAKE_VERSION VERSION_LESS 2.8.8
AND OpenCV_FIND_COMPONENTS # prevent excessive output
)
# HANDLE_COMPONENTS was introduced in CMake 2.8.8
list(APPEND _OpenCV_FPHSA_ARGS HANDLE_COMPONENTS)
# The missing components will be handled by the FindPackageHandleStandardArgs
# module.
set(_OpenCV_HANDLE_COMPONENTS_MANUALLY FALSE)
else()
# The missing components will be handled by this config.
set(_OpenCV_HANDLE_COMPONENTS_MANUALLY TRUE)
endif()
# Extract directory name from full path of the file currently being processed.
# Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it
# for older versions of CMake to support these as well.
...
...
@@ -120,24 +139,33 @@ endif()
set(OpenCV_WORLD_COMPONENTS @OPENCV_WORLD_MODULES@)
# expand short module names and see if requested components exist
set(OpenCV_FIND_COMPONENTS_ "")
foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
# Store the name of the original component so we can set the
# OpenCV_<component>_FOUND variable which can be checked by the user.
set (__original_cvcomponent ${__cvcomponent})
if(NOT __cvcomponent MATCHES "^opencv_")
set(__cvcomponent opencv_${__cvcomponent})
endif()
list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx)
if(__cvcomponentIdx LESS 0)
#requested component is not found...
if(OpenCV_FIND_REQUIRED)
message(FATAL_ERROR "${__cvcomponent} is required but was not found")
elseif(NOT OpenCV_FIND_QUIETLY)
message(WARNING "${__cvcomponent} is required but was not found")
endif()
if(_OpenCV_HANDLE_COMPONENTS_MANUALLY)
# Either the component is required or the user did not set any components at
# all. In the latter case, the OpenCV_FIND_REQUIRED_<component> variable
# will not be defined since it is not set by this config. So let's assume
# the implicitly set components are always required.
if(NOT DEFINED OpenCV_FIND_REQUIRED_${__original_cvcomponent} OR
OpenCV_FIND_REQUIRED_${__original_cvcomponent})
message(FATAL_ERROR "${__cvcomponent} is required but was not found")
elseif(NOT OpenCV_FIND_QUIETLY)
# The component was marked as optional using OPTIONAL_COMPONENTS
message(WARNING "Optional component ${__cvcomponent} was not found")
endif()
endif(_OpenCV_HANDLE_COMPONENTS_MANUALLY)
#indicate that module is NOT found
string(TOUPPER "${__cvcomponent}" __cvcomponentUP)
set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND")
set(OpenCV_${__original_cvcomponent}_FOUND FALSE)
else()
list(APPEND OpenCV_FIND_COMPONENTS_ ${__cvcomponent})
# Not using list(APPEND) here, because OpenCV_LIBS may not exist yet.
# Also not clearing OpenCV_LIBS anywhere, so that multiple calls
# to find_package(OpenCV) with different component lists add up.
...
...
@@ -145,6 +173,7 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
#indicate that module is found
string(TOUPPER "${__cvcomponent}" __cvcomponentUP)
set(${__cvcomponentUP}_FOUND 1)
set(OpenCV_${__original_cvcomponent}_FOUND TRUE)
endif()
if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent})
get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG)
...
...
@@ -170,7 +199,6 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
endif()
endif()
endforeach()
set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_})
# ==============================================================
# Compatibility stuff
...
...
@@ -226,3 +254,8 @@ macro(ocv_list_filterout lst regex)
endif()
endforeach()
endmacro()
# We do not actually need REQUIRED_VARS to be checked for. Just use the
# installation directory for the status.
find_package_handle_standard_args(OpenCV REQUIRED_VARS OpenCV_INSTALL_PATH
VERSION_VAR OpenCV_VERSION ${_OpenCV_FPHSA_ARGS})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment