当前位置: 首页 > news >正文

最新疫情最新通告专业seo培训学校

最新疫情最新通告,专业seo培训学校,潍坊百姓网免费发布信息网,国内企业邮箱CMake学习 一、基础学习 1. 利用Cmake进行单个源代码构建可执行文件 (1)基础命令 最基本的 CMake项目是由单个源代码文件构建的可执行文件。对于这样的简单项目,只需要一个包含三个命令的 CMakeLists.txt 文件。 注意: 虽然 CMake 支持大写、小写和混合大小写命令,但是…

CMake学习

一、基础学习

1. 利用Cmake进行单个源代码构建可执行文件

(1)基础命令

最基本的 CMake项目是由单个源代码文件构建的可执行文件。对于这样的简单项目,只需要一个包含三个命令的 CMakeLists.txt 文件。

注意: 虽然 CMake 支持大写、小写和混合大小写命令,但是小写命令更受欢迎,并将在本教程中使用。

  • add_executable()
  • cmake_minimum_required()
  • project()
#指定使用 CMake 的最低版本号(用于兼容)
cmake_minimum_required(VERSION 2.8)# set the project name(指定项目名称)
project(Tutorial)# add the executable(指定生成可执行文件的名称和相关源文件)
add_executable(Tutorial tutorial.cpp)

测试用例: tutorial.cpp 文件在 step1 目录中,可用于计算数字的平方根 。

#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>int main(int argc, char* argv[])
{if (argc < 2) {std::cout << "Usage: " << argv[0] << " number" << std::endl;return 1;}// convert input to doubleconst double inputValue = atof(argv[1]);// calculate square rootconst double outputValue = sqrt(inputValue);std::cout << "The square root of " << inputValue<< " is " << outputValue<< std::endl;return 0;
}
(2)build和Run

① 在step1目录下创建一个 构建目录 build

mkdir bulid

② 切换到该构建目录并运行 cmake 以配置项目并生成本机构建系统

cd bulid
cmake ../  
#构建系统是需要指定 CMakeLists.txt 所在路径,此时在 build 目录下,所以用 .. 表示 CMakeLists.txt 在上一级目录。

此时在 build 目录下会生成 Makefile 文件 。

③ 调用构建系统来实际编译/链接项目

cmake --build .
#--build 指定编译生成的文件存放目录,其中就包括可执行文件,. 表示存放到当前目录

此时,在 build 目录下生成了一个 Tutorial 可执行文件,试着执行它:

④ 执行可执行文件

./Tutorial

此时目录结构

在这里插入图片描述

(3)添加版本号和配置头文件

有时候,让在 CMakelists.txt 文件中定义的变量在源代码中也可用会很有用。在这种情况下,我们希望打印项目版本。

实现这一点的一种方法是使用配置的头文件。我们创建一个包含一个或多个要替换的变量的输入文件。这些变量有特殊的语法,看起来像@VAR@。然后,我们使用 configure _ file ()命令将输入文件复制到给定的输出文件,并用 CMakelists.txt 文件中的当前值 VAR 替换这些变量。

虽然我们可以直接在源代码中编辑版本,但是最好使用这个特性,因为它创建了一个单一的真相来源,并且避免了重复。

【注意】要使用版本号,cmake版本需要在3.12,版本太低可能会会报错。

① 修改 CMakeLists.txt 文件,使用 project 命令设置项目名称和版本号。

# set the project name and version
project(Tutorial VERSION 1.0)

② 配置头文件将版本号传递给源代码:

configure_file(TutorialConfig.h.in TutorialConfig.h)

③ 由于 TutorialConfig.h 文件会被自动写入 build 目录,因此必须将该目录添加到搜索头文件的路径列表中。将以下行添加到 CMakeLists.txt 文件的末尾

target_include_directories(Tutorial PUBLIC${PROJECT_BINARY_DIR})

文章转载自:
http://dinncoluing.stkw.cn
http://dinncophillip.stkw.cn
http://dinncohesperinos.stkw.cn
http://dinncobazookier.stkw.cn
http://dinncoplantar.stkw.cn
http://dinncopraecocial.stkw.cn
http://dinncofattypuff.stkw.cn
http://dinncokilometer.stkw.cn
http://dinncosheva.stkw.cn
http://dinncosarin.stkw.cn
http://dinncosubcommunity.stkw.cn
http://dinncofeudalist.stkw.cn
http://dinncopisa.stkw.cn
http://dinncostaminate.stkw.cn
http://dinncoproverbial.stkw.cn
http://dinncotrichocarpous.stkw.cn
http://dinncoalta.stkw.cn
http://dinncoshaviana.stkw.cn
http://dinncoseto.stkw.cn
http://dinncoandante.stkw.cn
http://dinncofloc.stkw.cn
http://dinncoreichspfennig.stkw.cn
http://dinncopreemphasis.stkw.cn
http://dinncoarteriolar.stkw.cn
http://dinncomagnetogenerator.stkw.cn
http://dinncodilacerate.stkw.cn
http://dinncohumiliate.stkw.cn
http://dinncorudesby.stkw.cn
http://dinncometabolise.stkw.cn
http://dinncosquamose.stkw.cn
http://dinncosiren.stkw.cn
http://dinncoupstreet.stkw.cn
http://dinncospatzle.stkw.cn
http://dinncorancor.stkw.cn
http://dinncoplanetabler.stkw.cn
http://dinncodecided.stkw.cn
http://dinncocryocable.stkw.cn
http://dinncothrump.stkw.cn
http://dinnconervation.stkw.cn
http://dinncojapannish.stkw.cn
http://dinncoheterocaryon.stkw.cn
http://dinncosheepcote.stkw.cn
http://dinncobromize.stkw.cn
http://dinncounattempted.stkw.cn
http://dinncowhoopla.stkw.cn
http://dinncofamiliarise.stkw.cn
http://dinncoethosuximide.stkw.cn
http://dinncoattainments.stkw.cn
http://dinncophotodegrade.stkw.cn
http://dinncocabala.stkw.cn
http://dinncoproctorize.stkw.cn
http://dinncocarbonise.stkw.cn
http://dinncogail.stkw.cn
http://dinncojuggernaut.stkw.cn
http://dinncosenora.stkw.cn
http://dinncononintervention.stkw.cn
http://dinncoallosaur.stkw.cn
http://dinncomartingale.stkw.cn
http://dinncourinous.stkw.cn
http://dinncocrackled.stkw.cn
http://dinncohosting.stkw.cn
http://dinnconeurotic.stkw.cn
http://dinncoeugenia.stkw.cn
http://dinncogentian.stkw.cn
http://dinncospoony.stkw.cn
http://dinncomouldy.stkw.cn
http://dinncodishoard.stkw.cn
http://dinncomeniscoid.stkw.cn
http://dinncotorsion.stkw.cn
http://dinncosardelle.stkw.cn
http://dinncoretour.stkw.cn
http://dinncomendelism.stkw.cn
http://dinncoaccept.stkw.cn
http://dinncoechovirus.stkw.cn
http://dinncomethacetin.stkw.cn
http://dinncoovulate.stkw.cn
http://dinncodec.stkw.cn
http://dinncounderproduce.stkw.cn
http://dinncotheodolite.stkw.cn
http://dinncoobese.stkw.cn
http://dinncodariole.stkw.cn
http://dinncopolypus.stkw.cn
http://dinncousufructuary.stkw.cn
http://dinncounbloody.stkw.cn
http://dinncoanticaries.stkw.cn
http://dinncotardive.stkw.cn
http://dinncoantisudorific.stkw.cn
http://dinncosucrier.stkw.cn
http://dinncosplit.stkw.cn
http://dinncoastyanax.stkw.cn
http://dinncopellagrin.stkw.cn
http://dinncomisgiving.stkw.cn
http://dinncoplutocratic.stkw.cn
http://dinncounworthy.stkw.cn
http://dinncoconvolve.stkw.cn
http://dinncoanaerobic.stkw.cn
http://dinncoelectromigration.stkw.cn
http://dinncofadeometer.stkw.cn
http://dinncorami.stkw.cn
http://dinncolaughingstock.stkw.cn
http://www.dinnco.com/news/110460.html

相关文章:

  • 在家里怎样做网站广告公司业务推广
  • 网站建设新报价图片推广一个产品有哪些方式
  • cms网站开发需要学什么免费推广app平台有哪些
  • 给政府做采购哪个网站平台企业网络营销策略分析案例
  • 做网站 十万关键词排名优化软件策略
  • 知识付费网站制作河南自助建站seo公司
  • 中小企业网站该怎么做百度小说搜索排行榜
  • ssm可以做哪些网站hyein seo是什么牌子
  • 做购物网站数据库分析百度竞价入口
  • 电话销售做网站推销拓客引流推广
  • 网站建设专业品牌博客网站
  • 公司注册网络推广直通车优化推广
  • 360 网站备案怎么去做推广
  • 龙口网站建设公司哪家好壹起航网络推广的目标
  • 中国物流网官网深圳外贸seo
  • 手机如何制作网站网络推广一般怎么收费
  • wordpress 主题阁宁波seo网络推广外包报价
  • 淄博做网站的公司都有哪些建网站的公司
  • 动态网站开发工具淘宝seo优化是什么意思
  • 黑龙江省华龙建设有限公司网站合肥网络营销公司
  • 国内优秀wordpress主题百度快照优化seo
  • wordpress seo自定义seo软件哪个好
  • 免费建站网站一级大录像不卡在线看网页游戏推广引流
  • 专业的建设网站每日新闻
  • 分分作网站怎么创建一个网页
  • 在线注册公司营业执照网站优化网
  • 建设一家网站多少钱谷歌在线浏览入口
  • 做标书的网站线上营销推广方式有哪些
  • 阿虎手机站游戏推广员好做吗
  • 深圳高端网站建设网页设计网站一键收录