[CMake] Install cmake under windows (pro-test is effective)

Table of contents

0. Preface

1. Download the cmake installation package file

2. Install cmake

3. Check whether the installation is successful


0. Preface

CMake is an open source cross-platform build tool for managing the build process of C/C++ projects. It uses concise syntax to describe build rules and dependencies, and outputs build system files (such as Makefiles, Visual Studio solutions, etc.) suitable for different operating systems and compilers in the form of a generator, thereby enabling project compilation, testing, and Packaging and other operations.

The design concept of CMake is to decouple the build process from the underlying build system, allowing developers to build on different platforms and compilation environments more flexibly. It provides concise CMakeLists.txt files to describe the structure and dependencies of the project. These files are similar to scripts and can define the project's build process through instructions and variables.

The following are some important features and concepts of CMake:

  1. Cross-platform support : CMake can generate build system files for various operating systems and compilers, including Linux, Windows, macOS, and more.

  2. Automated build : CMake automatically generates compilation rules and link options required to build the system by analyzing source code and configuration information, reducing manual configuration and maintenance work.

  3. Modular design : CMake uses a modular approach to organize and manage projects. It can split complex projects into multiple subdirectories and use add_subdirectorycommands to build modules in these subdirectories.

  4. Dependency management : CMake supports the integration and management of external libraries. You can use find_packagethe command to find and configure the required third-party libraries, and use target_link_librariesthe command to link them into the project.

  5. Multi-configuration support : CMake supports multi-configuration builds, and you can set different build types according to your needs, such as Debug, Release, etc.

  6. Extensibility : CMake supports custom functions, macros, variables, etc. Developers can write their own CMake modules to meet specific needs.

The general steps to build a project using CMake are as follows:

  1. Create a CMakeLists.txt file and write the build rules and project configuration.
  2. Create a folder for building (such as build) in the project root directory and enter the folder.
  3. Run CMake commands to generate build system files appropriate for the current platform and compiler.
  4. Use the generated build system for compilation and build operations.

CMake provides a rich set of commands and variables for describing source code, compilation options, link libraries, etc. You can refer to CMake's official documentation ( https://cmake.org/documentation/) to learn more about its functions and usage.

1. Download the cmake installation package file

CMake is a cross-platform build tool for managing the build process of C/C++ code. It uses a text file named CMakeLists.txt to define build rules and dependencies, and generates corresponding build system files (such as Makefiles or Visual Studio solutions) for subsequent compilation and building of the project.

Index of /filesicon-default.png?t=N7T8https://cmake.org/files/

The direct download speed from the cmake official website is very slow.

Select the file corresponding to x86_64.msi to download.

2. Install cmake

It should be noted that you need to choose to add the cmake path , so that you don't have to manually add the path later, which can save a lot of trouble. 

Select installation path:

3. Check whether the installation is successful

Guess you like

Origin blog.csdn.net/fanjufei123456/article/details/132753095