Skip to content

Added BUILD_LIST - #9893

Merged
opencv-pushbot merged 1 commit into
opencv:masterfrom
mshabunin:add-modules-whitelist
Nov 23, 2017
Merged

opencv-pushbot merged 1 commit into
opencv:masterfrom
mshabunin:add-modules-whitelist

Conversation

@mshabunin

@mshabunin mshabunin commented Oct 20, 2017 •

Copy link
Copy Markdown
Contributor

This pullrequest changes

adds ability to build only modules which you really need:

> cmake -DBUILD_LIST=dnn ../opencv && make
> ls -1 lib
libopencv_core.so
libopencv_core.so.3.3
libopencv_core.so.3.3.0
libopencv_dnn.so
libopencv_dnn.so.3.3
libopencv_dnn.so.3.3.0
libopencv_imgproc.so
libopencv_imgproc.so.3.3
libopencv_imgproc.so.3.3.0

Notes:

  • modules should be named as folders: core, imgproc, ...; not opencv_core
  • modules can be delimited by space, comma, colon, semicolon: -DBUILD_LIST=dnn,imgcodecs; don't forget to escape shell's special characters -DBUILD_LIST=dnn\;imgcodecs
  • to build a world module:
    • add imgcodecs, videoio, highgui to the list: -DBUILD_LIST=dnn,imgcodecs,videoio,highgui
    • add -DBUILD_opencv_world=ON option
  • to build tests add a ts module: -DBUILD_LIST=dnn,ts
  • to build samples add -DBUILD_EXAMPLES=ON option and enable dependent modules as follows:
    • opencv/samples/cpp ➡️ flann,imgcodecs,videoio,highgui,ml,video,objdetect,photo,features2d,calib3d,stitching,videostab,shape
    • opencv/samples/dnn ➡️ dnn,imgcodecs,videoio,highgui
    • some_module/samples ➡️ some_module,imgcodecs,videoio,highgui
  • to build wrappers add them to the list: -DBUILD_LIST=dnn,imgcodecs,python3,java (java has hidden dependency on imgcodecs, it should be fixed)
  • optional dependencies (ocv_define_module(<module> <required_deps> OPTIONAL <optional_deps>) are not taken in account so you should enable them manually
  • tested with cmake 3.7.2

@alalek

alalek commented Oct 23, 2017

Copy link
Copy Markdown
Member

Implementation looks good to me.

But current name seems confusing ("whitelist" usually should not disable anything).
There are possible changes of option name:

  • OPENCV_MODULES
  • OPENCV_ENABLE_MODULES
  • OPENCV_FORCE_MODULES
  • MODULES_LIST / OPENCV_MODULES_LIST
  • BUILD_MODULES (very generic) / OPENCV_BUILD_MODULES
  • BUILD_WISHLIST (non-formal)

BTW, there are internal CMake vars:OPENCV_MODULES_BUILD / OPENCV_MODULES_PUBLIC.

/cc @vpisarev

@alalek

alalek commented Nov 9, 2017

Copy link
Copy Markdown
Member

Ping, another variant for variable name is OPENCV_SELECT_MODULES

@mshabunin

Copy link
Copy Markdown
Contributor Author

In my opinion, word whitelist is quite intuitive, for example it can be defined as follows (source):

A whitelist is a list of items that are granted access to a certain system or protocol. When a whitelist is used, all entities are denied access, except those included in the whitelist. The opposite of a whitelist is a blacklist, which allows access from all items, except those included the list.

I also like variants BUILD_WISHLIST (because it does not guarantee that chosen modules will be built) and BUILD_ONLY / BUILD_ONLY_MODULES / BUILD_NOTHING_BUT.

@vpisarev

Copy link
Copy Markdown
Contributor

I vote for BUILD_LIST

@mshabunin
mshabunin force-pushed the add-modules-whitelist branch from 176b4d7 to 5b17410 Compare November 23, 2017 13:06
@mshabunin

Copy link
Copy Markdown
Contributor Author

Renamed.

@opencv-pushbot
opencv-pushbot merged commit 5b17410 into opencv:master Nov 23, 2017
@mshabunin
mshabunin deleted the add-modules-whitelist branch January 30, 2018 11:44
@IMG-PRCSNG

IMG-PRCSNG commented Jun 27, 2018 •

Copy link
Copy Markdown

The bindings generator seems to generate bindings even for the modules that are not being built. Any Idea on how to handle it? Or is there a configuration option that needs to be set additionally?

Update: False Alarm.

But the issue is that if I include features2d but not include flann in the BUILD_LIST, it is failing at the build phase of the bindings and not at the dependency resolution in cmake phase. Any Idea why?

@xiebaiyuan

Copy link
Copy Markdown

wow i vote for it too

@rosaline1995

Copy link
Copy Markdown

May I ask if it's enough to create a normal CMakeList.txt file and then run "cmake -DBUILD_LIST=mgcodecs,videoio,highgui" so that opencv will work as expected, which means, all modules are turned off except those in the options?

But after I did so on my MacBook (with macOS 10.15.1), why did I get a warning saying that
"CMake Warning:
Manually-specified variables were not used by the project:"?
And then, my program ran with this line of code "std::cout << cv::getBuildInformation() << std::endl;" and still printed:
"Parallel framework: TBB (ver 2019.0 interface 11008)

Trace: YES (with Intel ITT)

Other third-party libraries:
Intel IPP: 2019.0.0 Gold [2019.0.0]
at: /tmp/opencv-20190826-34514-r5q5gz/opencv-4.1.1/build/3rdparty/ippicv/ippicv_mac/icv
Intel IPP IW: sources (2019.0.0)
at: /tmp/opencv-20190826-34514-r5q5gz/opencv-4.1.1/build/3rdparty/ippicv/ippicv_mac/iw
Lapack: YES (/usr/local/opt/openblas/lib/libopenblas.dylib)
Eigen: YES (ver 3.3.7)
Custom HAL: NO
Protobuf: build (3.5.1)

OpenCL: YES (no extra features)
Include path: NO
Link libraries: -framework OpenCL".

I felt that it meant at least OpenCL and IPP were not turned off. Is that correct? So did I use this option in a wrong way or is it simply because cmake doesn't work well with macOS 10.15+?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants