GithubHelp home page GithubHelp logo

cmaketutorial's Introduction

CMake教程

简介

官网:https://cmake.org/

CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice.

开源,跨平台的构建,测试,打包软件工具, 使用简单平台和独立于编译器的配置文件来控制软件编译过程, 生成可在您选择的编译器环境中使用的本机makefile和工作区

画重点:

  • 配置文件:cmake脚本(命令/语法)
  • 构建:CMake
  • 测试:CTest
  • 打包:CPack

CMake是什么?

提供一组工具, 可以在不同平台上配置、构建、测试和部署项目. https://www.aosabook.org/en/cmake.html

CMake是一个构建系统生成器(build system generator), 不是build system

image-20210621103712644

  • 支持主流的build system:Make, Ninja, Visual Studio, XCode, ...
  • 跨平台:Linux, Windows, OSX, ...

有大一统的趋势. 越来越多的第三方库提供 CMake 配置, 包括QT, Android NDK官方支持CMake

Jetbrain 2020调查

CPP:

image-20210601003717844

安装:

地址:https://cmake.org/download/

CMake两个重要版本:

  • Modern CMake: CMake 3.0+
  • More Modern CMake: CMake 3.12+

命令行版本 vs 界面版本

界面版本都是对命令行版本的包装和可视化,这里也只讲命令行版本,cmake命令行会了,在去使用界面版本的问题不大

其它需要安装环境:

学习步骤:

官方文档教程存在的问题:

  • 官方教程CMake Tutorial, 学习步骤顺序没有问题;问题是内容精简得,里面很多概念不会跟你解释
  • CMake的官方文档更像是个手册,方便查询的那种;

知乎某某的吐槽: 虽然官方的documentation很详细, 但特么都是描述性的。也就是说CMake告诉你他能做什么, 我有多屌, 但是他不告诉你该怎么做, 以及为什么要这么做。从而开发过程就变成了一个试错过程

无法作为一种渐进的,结构化的学习CMake的方式

本教程步骤:

helloworld开始, 然后会讲一些cmake脚本中的常用命令,循序渐进,中间会穿插讲解很多概念解释

  1. helloworld示例
  2. cmake常用脚本命令(CMakeLists.txt)
  3. 生成target(可执行程序/动态库/静态库)
  4. CMake的模块
  5. 项目引入三方库
  6. 交叉编译
  7. 安装/打包

本教程的前提假设:

  • 你会使用gcc编译代码或项目,使用过动态库,静态库,设置过一些编译选项,知道编译是怎么一回事(流程)
  • 能看懂或会写简单的Makefile

Reference:

书籍推荐:

CMake Cookbook

Professional CMake

自行寻找资源

资源:

Github:awesome-cmake:

视频:

cmaketutorial's People

Contributors

wshibin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.