Install CMake on Windows

Introduction to CMake

CMake is an open source, cross-platform automated build system used to manage the software build process.

Its main uses include:

1. Cross-platform compilation: CMake supports multiple operating systems such as Windows, Mac OS, and Linux, and supports most mainstream compilers such as GCC, Clang, Visual Studio, etc.

2. Manage large-scale projects: Different functional modules can be compiled and managed separately, and their dependencies can be defined in CMakeLists, which is helpful for the organization and maintenance of software projects.

3. Testing: CMake’s own CTest tool can add unit tests to facilitate testing of projects.

4. Packaging: You can use the CPack tool to create an installation package.

5. Multiple build methods: You can set multiple build targets, including executable files, library files, and custom commands.

Through CMake, software developers can more easily conduct cross-platform development and project management.

Install CMake on Windows

1. CMake official website download address: Download CMake

   What I downloaded is cmake-3.27.6-windows-x86_64.msi

2. Double-click to run and start the installation.

w2.png

3. Check the box to agree to the agreement.

w1.png

4. Add environment variables (you can add shortcuts on the left).

q5.png

5. Change the installation directory and try not to include Chinese characters.

q4.png

6. Click Next to start Install.

q3.png

7. The installation is completed.

q2.png

8. Enter cmake in CMD. If the following information is displayed, the installation is successful.

q1.png

Summary of common commands for Windows CMake

On Windows systems, the commonly used cmake instructions are as follows:

1. cmake -version: displays the current CMake version.

2. cmake .: Generate build files in the current directory.

3. cmake -G "generator-name": Generates the build file of the specified generator. For example: "Visual Studio 16 2019" is used to generate project files for Visual Studio 2019.

4. cmake -DCMAKE_BUILD_TYPE=Release.: Specify the build type as daily release.

5. cmake -DCMAKE_INSTALL_PREFIX=/path/to/install: Specify the installation directory path.

6. cmake --build .: Compile source code.

7. cmake --build . --target install: Compile source code and install.

8. cmake --build . --config Release: Specify the build configuration for release.

9. cmake --build . --target clean: Clean the project build.

10. cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=YES .: Export compilation instructions to the compile_commands.json file.

Guess you like

Origin blog.csdn.net/zhouzhiwengang/article/details/133430457