Note of cmake quick start
1.Install cmake
2.Write your cpp program
1 2 3 4 5 6 7 8 9 10 11 12
| #include <iostream>
int main() { std::cout << "Hello cpp!" << std::endl;
int a = 10; int b = a * 2; std::cout << "b is " << b << std::endl;
return 0; }
|
3.Write CMakeLists.txt in project directory
1 2 3 4 5 6 7 8
| cmake_minimum_required(VERSION 3.15)
project(Maintest)
add_executable(Maintest main.cpp)
|
4.Make directory build and into it to init cmake, then build the project.
1 2 3 4
| mkdir build cd build cmake .. cmake --build .
|
Now, you can see all the build files in build directory, you can run program like this