Ask Your Question
1

How to set CMake options to compile some modules only?

asked 2018-09-06 01:38:55 -0600

laurencedev gravatar image

updated 2018-09-06 02:16:35 -0600

We can set the options like the following to compile some but not others:

-DBUILD_opencv_xfeatures2d=ON
-DBUILD_opencv_apps=OFF

As the above, my understanding is xfeatures2d will be compiled (The Makefiles will set it as a target for compilation) and apps definitely not, but other modules haven't specified in the options will be compiled by default. However, if apps is required for xfeatures2d then xfeatures won't be compiled and cmake output will warning this.

What the problems with the above understanding ?

Is there a way to say compile xfeatures2d and the modules it required only ?

Furthermore, is there a way to say compile xfeatures2d and the modules it required and optionally required ones?

How about the WITH options, like -DWITH_1394=OFF, what is the default values for them ? Or, by default, it depends on the environment its running on? For instance, if CMake can find all (local) libraries needed for CUDA, -DWITH_CUDA will be ON by default.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2018-09-06 03:19:38 -0600

berak gravatar image

i can only partly answer this, but here are some bulletpoints:

  • there is a BUILD_LIST feature, where you can specify the modules you want , overriding the existing BUILD_opencv_xxxx=ON settings. you'd use it like:

    cmake -DBUILD_LIST=dnn,core,calib3d,imgproc,imgcodecs,highgui
    

    (comma seperated modulenames without opencv_ prefix)

  • to pick up your xfeatures2d example: each module has a CmakeLists.txt, where you can find its dependancies , in this case:

    opencv_core opencv_imgproc opencv_features2d opencv_calib3d
    

    are mandatory. (... then you'll find out, that features2d needs flann ;)

  • you have to carefully watch the cmake output for lines like:

    module xxxx disabled because of missing dependancy yyyy
    

    before you can run configure or make

edit flag offensive delete link more

Comments

1

Thanks @berak, this is what exact what i am looking for! For others who were confused also: 1. BUILD_LIST is acting like a white list function, only the ones specified will be built given their required ones (dependency) are specified too . Ref def here; 2. Normally, the dependency are list in ocv_define_module of their CMakeLists.txt, for some cases, try ocv_add_module.

laurencedev gravatar imagelaurencedev ( 2018-09-06 11:20:28 -0600 )edit

No similar white list found for WITH_* yet, but all components are list in HERE

laurencedev gravatar imagelaurencedev ( 2018-09-06 12:38:50 -0600 )edit
0

answered 2018-09-06 02:47:44 -0600

ak1 gravatar image

Yes you can set specific flags needed by you. I prefer using GUI or ccmake . Enter following commands in your terminal

Step1. Change the directory to opencv build folder. 
Step2. $ ccmake .

List of all the modules and flags will be displayed on the screen.

Step3. Now set the flags ON/OFF using enter key. 
Step4. Press c to configure changes.
Step5. Press g to generate files.

After this you can do make and install

edit flag offensive delete link more

Comments

Hi, @ak1, thanks for the response. Get some interesting findings on the way you mentioned also. Thanks bro !

laurencedev gravatar imagelaurencedev ( 2018-09-06 11:44:33 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-09-06 01:38:55 -0600

Seen: 7,732 times

Last updated: Sep 06 '18