当前位置:网站首页>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
边栏推荐
- Pam4 popular science
- 2022 Hangzhou Electric Multi school first Dragon Slayer (dfs+ state compression)
- Why is gradient the fastest changing direction of function
- 【JVM学习03】类加载与字节码技术
- [JVM learning 03] class loading and bytecode Technology
- MySQL final chapter
- MySQL sort. Sort by field value
- JVM方法调用
- Hangdian multi School Game 1 question 3 backpack (XOR dp+bitset)
- Common methods of string class
猜你喜欢

OpenGL learning (II) opengl rendering pipeline

Convolutional Neural Networks in TensorFlow quizs on Coursera

Day 10 (inheritance, rewriting and use of super)

【校招面经】8道指针面试真题,快来检测自己掌握了几道。

2022 Hangdian multi school second session 1009 shuangq (Mathematics)

Sqoop

LSTM and Gru of RNN_ Attention mechanism

Why are there loopholes in the website to be repaired

FPGA 20 routines: 9. DDR3 memory particle initialization write and read through RS232 (Part 2)

原反补及大小端
随机推荐
Math
Chapter 4 compound type
OPENGL学习(二)OPENGL渲染管线
Introduction to VIM
思源笔记 v2.1.2 同步问题
Convolutional Neural Networks in TensorFlow quizs on Coursera
Mysql数据库,去重,连接篇
About core files
High speed ASIC packaging trends: integration, SKU and 25g+
Mysql数据库,子查询,union,limit篇
Convolutional neural network CNN
day 2
Cesium uses czml to implement dynamic routes
Tcl/tk grouping and replacement rules
MySQL8.0学习记录20 - Trigger
Feature extraction tool transformer Bert
SATA protocol OOB essay
Decision tree_ ID3_ C4.5_ CART
TCL programming style guide
[JVM learning 03] class loading and bytecode Technology