How to use CMake?

I am trying to use CMake to compile opencv.

I am reading a tutorial , but I can’t understand what are CMakeLists files and how is it related to gui from CMake?

Also could not understand what make files are, are they similar to CMakeLists?

And what file should I open in Visual Studio?

+82
c ++ visual-studio cmake
Oct 22 '11 at 12:46
source share
5 answers

CMake accepts a CMakeList file and displays it in the build format of a specific platform, for example. Makefile, Visual Studio, etc.

First you run CMake in a CMakeList. If you are working in Visual Studio, you can download the output project / solution.

+26
Oct 22 '11 at 12:58
source share

I don't know about Windows (I never used it), but on a Linux system you just need to create an assembly directory (in the top source directory)

mkdir build-dir 

go inside

 cd build-dir 

then run cmake and point to the parent directory

 cmake .. 

and finally run make

 make 

Please note that make and cmake are different programs. cmake is a Makefile generator, and the make utility is controlled by a Makefile text file. See cmake & make wikipedia.

NB. On Windows, cmake may work, so you need to use it differently. You need to read the documentation (as I did for Linux)

+114
Oct 22 '11 at 12:53
source share

Yes, cmake and make are different programs. cmake has (on Linux) a Makefile generator (and Makefile-s are the files that control the make utility). There are other Makefile generators (in particular, configure and autoconf, etc.). And you can find other build automation programs (like ninja ).

+8
Oct 22 '11 at 13:01
source share

CMake is an extensible open source system that manages the build process in the operating system regardless of the compiler .... CMake can generate its own build environment that will compile the source code, create libraries, create wrappers and create executable files in arbitrary combinations.

0
Dec 20 '18 at 8:53
source share

Regarding CMake 3.13.3, the Windows platform, and the Visual Studio 2017 IDE, I suggest:
1. Go to https://cmake.org/download/, scroll down the page, in the second list "Platform" find "Windows win32-x86 ZIP" and click "cmake-3.13.3-win32-x86.zip".
2. In the download window, right-click the empty area and select "Extract All Files".
3. In the window that appears, leave the suggested path and click "Extract."
4. After the extraction is complete, go to ...> Downloads> "cmake-3.13.3-win32-x86"> "cmake-3.13.3-win32-x86"> the "Bin" folder> the double-click file "cmake-qui" "> in the window that opens, double-click" Run. "The CMake wizard appears on your screen.
5. As an example, download GLFW from https://www.glfw.org/download.html by selecting "Source Package".
6. In the download window, right-click the empty area and select "Extract All Files".
7. In the window that appears, leave the suggested path and click "Extract."
8. After the extraction is complete, go to ...> Downloads> "glfw-3.2.1"> "glfw-3.2.1". Inside, right-click and select New> Folder> enter the name Build without quotation marks.
9. In the CMake wizard, next to the first text box, click "Browse Source ..." and go to ...> Downloads> glfw-3.2.1> glfw-3.2.1. Click Select Folder. The first path should be "... / Downloads / glfw-3.2.1 / glfw-3.2.1". The second path should be "... / Downloads / glfw-3.2.1 / glfw-3.2.1 / Build".
10. In the CMake wizard, click Configure. In the window that appears, click "Finish." When you see a red background and read “Setup Complete,” click “Configure” again. The red background fades. Click Create. You read "Creation Complete."
11. Go to ... \ Downloads \ glfw-3.2.1 \ glfw-3.2.1, double-click the folder you created "Build"> inside the search file "ALL_BUILD.vcxproj" or GLFW.sln. Double click on it. A Visual Studio instance will appear> in the main menu, click Build> Build Solution.
12. Wait until you read “Build: 28 completed, 0 not completed, 0 updated, 2 skipped” in the “Output” window.
13. Go to ...> Downloads> glfw-3.2.1> glfw-3.2.1> Build> src> Debug. Get the file "glfw3.lib". Sincerely.

0
Jan 24 '19 at 10:45
source share



All Articles