Table of contents
02. Generate compilation project files
01. Create a Cmake folder
Internally contains HelloWorld.cpp, CMakeLists.txt.
HelloWorld.cpp:
#include <iostream>
using namespace std;
int main() {
cout<<"HelloWorld"<<endl;
system("pause");
return 0;
}
CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (HelloWorld)
add_executable (HelloWorld HelloWorld.cpp)
02. Generate compilation project files
Enter the cmake folder directory and run the command
cmake .
03. Compile the project
Run the command (note: the default is Debug mode)
cmake --build .
To run in Release mode, replace with the following command
cmake --build . -- /p:Configuration=Release
04. Run the program
Go to the directory with the exe (under the Debug or Release folder)
cd Debug //或者是 cd Release
Execute HelloWorld.exe
HelloWorld.exe
Output result: