[Solved] cmake error ‘the source does not appear to contain CMakeLists.txt’
I’m installing opencv in ubuntu 16.04. After installing the necessary prerequisites I used the following command:-
[email protected]:~/opencv_contrib$ mkdir build
[email protected]:~/opencv_contrib$ cd build
[email protected]:~/opencv_contrib/build$
[email protected]:~/opencv_contrib/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX+/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D BUILD_EXAMPLES=ON ..
but it produced an error:-
CMake Error: The source directory "/home/kvs/opencv_contrib" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
I used the command provided in the folder ‘module’ documentation. How do I solve it?
I tried the answers here at stack-overflow and a few other question but still can’t figure it out.
Project Git repository here.
Solution #1:
You should do mkdir build
and cd build
while inside opencv
folder, not the opencv-contrib
folder. The CMakeLists.txt
is there.
Solution #2:
Since you add ..
after cmake, it will jump up and up (just like cd ..
) in the directory. But if you want to run cmake under the same folder with CMakeLists.txt, please use .
instead of ..
.
Solution #3:
This reply may be late but it may help users having similar problem.
The opencv-contrib (available at https://github.com/opencv/opencv_contrib/releases) contains extra modules but the build procedure has to be done from core opencv (available at from https://github.com/opencv/opencv/releases) modules.
Follow below steps (assuming you are building it using CMake GUI)
-
Download openCV (from https://github.com/opencv/opencv/releases) and unzip it somewhere on your computer. Create build folder inside it
-
Download exra modules from OpenCV. (from https://github.com/opencv/opencv_contrib/releases). Ensure you download the same version.
-
Unzip the folder.
-
Open CMake
-
Click Browse Source and navigate to your openCV folder.
-
Click Browse Build and navigate to your build Folder.
-
Click the configure button. You will be asked how you would like to generate the files. Choose Unix-Makefile from the drop down menu and Click OK. CMake will perform some tests and return a set of red boxes appear in the CMake Window.
-
Search for “OPENCV_EXTRA_MODULES_PATH” and provide the path to modules folder (e.g. /Users/purushottam_d/Programs/OpenCV3_4_5_contrib/modules)
-
Click Configure again, then Click Generate.
-
Go to build folder
# cd build
# make
# sudo make install
- This will install the opencv libraries on your computer.