Add COMPONENTS support to the OpenCVConfig.cmake (Feature #843)


Added by Adrien BARRAL about 14 years ago. Updated about 13 years ago.


Status:Done Start date:
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:build/install
Target version:2.4.0
Difficulty: Pull request:

Description

Hello,

I use OpenCV thank's to cmake... So I do :
find_package(OpenCV REQUIRED)

All works fine. But I have some programs which don't use some modules of
OpenCV, and I would like to be able to do :
find_package(OpenCV COMPONENTS opencv_core opencv_imgproc)
My goal is to minimize the library dependency of my programs.

I think this could be done replacing the following line in the
OpenCVConfig.cmake :
set(OPENCV_LIB_COMPONENTS opencv_core opencv_imgproc opencv_features2d opencv_gpu opencv_calib3d opencv_objdetect opencv_video opencv_highgui opencv_ml opencv_legacy opencv_contrib opencv_flann)

By these lines :

list(LENGTH OpenCV_FIND_COMPONENTS COMPONENTS_COUNT)
if(${COMPONENTS_COUNT} EQUAL 0)
set(OPENCV_LIB_COMPONENTS opencv_core opencv_imgproc opencv_features2d opencv_gpu opencv_calib3d opencv_objdetect
opencv_video opencv_highgui opencv_ml opencv_legacy opencv_contrib opencv_flann)
else(${COMPONENTS_COUNT} EQUAL 0)
set(OPENCV_LIB_COMPONENTS ${OpenCV_FIND_COMPONENTS})
endif(${COMPONENTS_COUNT} EQUAL 0)

I am a CMake newbie so i think that my patch proposition could be enhancend.

Cheers,

A. BARRAL


Associated revisions

Revision 4f26f0c2
Added by Vadim Pisarevsky almost 12 years ago

Merge pull request #843 from pengx17:2.4_stereobp_fix

History

Updated by Alexander Shishkov about 13 years ago

  • Description changed from Hello, I use [[OpenCV]] thank's to cmake... So I do : find_package(OpenC... to Hello, I use OpenCV thank's to cmake... So I do : find_package(OpenCV RE... More

Updated by Andrey Kamaev about 13 years ago

The feature is implemented in OpenCV trunk.

Both full module names (e.g. "opencv_video") and their short forms (e.g. "video") are accepted.

You can check the presence of components checking the OPENCV_<MODULE_NAME>_FOUND variables (for example OPENCV_HIGHGUI_FOUND will be set to TRUE if the highgui module is available).

  • Subject changed from Is it possible to make CMakeLists.txt more modular to Add COMPONENTS support to the OpenCVConfig.cmake
  • Status changed from Open to Done
  • Target version set to 2.4.0

Also available in: Atom PDF