当前位置:网站首页>Cmake series tutorial 1- initial cmake
Cmake series tutorial 1- initial cmake
2022-07-24 19:22:00 【senseshield】
What is? CMake
CMake It's a Cross platform Installation ( compile ) Tools , Can use simple 、 Unified statement to describe the installation or compilation process of all platforms . Can output the output of different compilers makefile or project file .
CMake Use CMakeLists.txt As a project organization document ,CMake Not a cross platform compilation tool , It's a project building tool , Engineering projects can be generated on different platforms according to construction parameters , for example Windows Can be built under the platform Visual Studio engineering or NMake engineering , Optional designation Visual Studio Version of ; stay Unix structure Makefile engineering .
CMake What can be done
- The project build
- Building complex projects
- Build cross platform projects
- project management
- Large projects are interdependent
- Project function extension adaptation
- unit testing
- ctest
- Continuous construction
- Packaging releases
- cpack
Why use CMake
- Source control
Organize a large number of project source code files by writing simple scripts , Dependency libraries, macro definitions, etc , Code files can be saved and named as needed , from CMakeLists.txt File organization code file relationship , In particular, cross project common module management . - Unified settings for complex projects
CMake With hierarchical inheritance , Subfolder of CMakeLists.txt The file will automatically integrate the public properties set by the parent directory , All reference library directories that need unified management 、 Project property settings 、 Macro definitions, etc. only need to be at the top CMakeLists.txt Set in the file to share the settings . - Build across platforms
Don't worry about Windows Use bat Complete the project build ,Unix Use shell As a build script , Just one set CMake Scripts are compatible with different platforms 、 compiler . - Good scalability
CMake Scripts have programmable features , It has similar extensibility to scripting language , Developers can organize through simple programming and logic , Compatible with various complex environments and various construction parameters . - Integration with third-party libraries
In normal projects, it is inevitable to reference mature third-party libraries ,CMake Allow by adding - Continuous integration
CMake Support the command line method to call , A continuously integrated platform only needs to be installed and deployed CMake Environmental Science , The batch 、shell、python Wait for the script to execute simple commands to build the project and compile , Lay a good foundation for continuous integration . - Open source project building tools
Many well-known cross platform open source projects use CMake As a source code building tool , for example : cURL, OGRE, OpenCV, LLVM and Clang, Qt, ZeroMQ etc. . The tools and code bases that God is using must be outstanding , Not to mention the common choice of many excellent open source works .
How to download and deploy CMake
Installation and deployment
visit CMake Official website , stay The download page Select the corresponding platform installation package , Download and install .
Windows
- Download installation package
stay Windows Installation under system CMake, Recommended download*.msiFormat installation package , Search page , Search for keywordswin64-x64.msiDownload link for (cmake-3.15.0-rc2-win64-x64.msi), Click to download . - install
Double click to run the downloaded installation package , Follow the prompts of the installation tool to install to the specified directory of the computer . - Installation successful
Start the command line prompt (CMD), Inputcmake --versionconfirm CMake Installation successful , And set the environment variables correctly , Successful installation will output installation CMake Version information for .C:\WINDOWS\system32>cmake –version
cmake version 3.15.0 CMake suite maintained and supported by Kitware (kitware.com/cmake).
Unix
- Download the source code
Search the page for*.tar.gzSuffix's compression package (cmake-3.15.0-rc2.tar.gz), Click to download . - Decompress the source code
stay Unix Extract and release the source code to the current directory in the environment , And switch to the source directory .tar xvf cmake-3.15.0-rc2.tar.gz
cd cmake-3.15.0-rc2 - Compile source code ./configure
make- perform ./configure, Check the current environment , Determine the installed code base of the environment , Generate the configuration files required for the build , Prepare for code compilation .
- make Compiled source code .
- Source code installation sudo make install The installation needs to copy the files to the root directory , Corresponding file read and write permissions are required (sudo).
- Installation successful
Start the terminal , Inputcmake --versionconfirm CMake Installation successful , And set the environment variables correctly , Successful installation will output installation CMake Version information for .
MacOS
- Download installation package
choice*.dmgDownload link for (cmake-3.15.0-rc2-Darwin-x86_64.dmg), Click to download . - install
Double-click on the run cmake-3.15.0-rc2-Darwin-x86_64.dmg Installation . - Installation successful
Start the terminal , Inputcmake --versionconfirm CMake Installation successful , And set the environment variables correctly , Successful installation will output installation CMake Version information for .
CMake Supported compilers
After successful installation , You can input cmake -h see CMake Parameter description of supported compilers and tools .
- Visual Studio( Various versions )
- NMake Makefiles
- Borland Makefiles
- Unix Makefiles
- CodeBlocks (MinGW/NMake/Unix Makefiles)
- CodeLite (MinGW/NMake/Unix Makefiles)
- Eclipse CDT4 (MinGW/NMake/Unix Makefiles)
- Kate (MinGW/NMake/Unix Makefiles)
- Sublime (MinGW/NMake/Unix Makefiles)
Learning path
- Introductory tutorial . Learn a brief tutorial about CMake The basic use method .
- CMake Variables and basic syntax . Practice Mastery CMake Variable declaration and common syntax use .
- CMake Advanced Grammar . Use CMake Write macros and functions to realize flexible and extensible project settings .
- Compilation options . Combine the compilation options of compilers on different platforms , Use CMake Set the variables and tools provided .
Learning resources
CMake A brief tutorial ( chinese )
CMake A brief tutorial ( english )
CMake Official documents v3.15
more CMake course :Virbox Technology blogs
边栏推荐
- Environment preparation of Nacos configuration center
- Meshlab&PCL ISS关键点
- OPENGL学习(四)GLUT三维图像绘制
- Channel state information (CSI) conjugate multiplication denoising method
- Nftscan and port3 have reached strategic cooperation in the field of NFT data
- On July 31, 2022, the dama-cdga/cdgp data governance certification class was opened!
- Compressed string
- Tcl/tk file operation
- Jedi survive and eat chicken F12 screenshot save path reference
- Unity code imports packages through package manager
猜你喜欢

matplotlib
Siyuan notes V2.1.2 synchronization problem

Day 10 (inheritance, rewriting and use of super)

Techempower web framework performance test 21st round results release --asp Net core continue to move forward

文献阅读:GoPose 3D Human Pose Estimation Using WiFi

Nacos简介和控制台服务安装

day 1

Clion configuring WSL tool chain

Decision tree_ ID3_ C4.5_ CART

拿捏C指针
随机推荐
Leetcode402 remove K digits
OpenGL learning (IV) glut 3D image rendering
Feature extraction tool transformer Bert
day 3
Taokeeper environment setup
Summary of articles in 2020
Sequences, time series and prediction in tessorflow quizs on coursera (I)
Cadence OrCAD capture tcl/tk script example
day 1
Wireshark simple filter rule
Ensure the health and safety of front-line construction personnel, and implement wrong time construction at Shenzhen construction site
Convolutional Neural Networks in TensorFlow quizs on Coursera
Get module handle / base address
Why is gradient the fastest changing direction of function
Tencent Browser service TBS usage
Mysql数据库,去重,连接篇
Introduction to VIM
MySQL final chapter
思源笔记 v2.1.2 同步问题
asp. Net core, C # summary about path