cmake-hello

一, 目录结构

├── CMakeLists.txt
├── main.cpp

* link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run
* link:main.cpp[main.cpp] - A simple "Hello World" cpp file.

 

二,cmake基本脚本

cmake_minimum_required(VERSION 3.5)

# Set the project name
project (hello_cmake)

aux_source_directory(. DIR_TOOT_SRCS)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

# Add an executable
add_executable(hello_cmake ${DIR_TOOT_SRCS})

 

三,cmake代码分析

 

### cmake最低版本

When creating a project using CMake, you can specify the minimum version
of CMake that is supported.

cmake_minimum_required(VERSION 3.5)


### 项目名称

A CMake build can include a project name to make referencing certain
variables easier when using multiple projects.

project (hello_cmake)


### 创建可执行程序

The +add_executable()+ command specifies that an executable should be
build from the specified source files, in this example main.cpp. The
first argument to the +add_executable()+ function is the name of the
executable to be built, and the second argument is the list of source files to compile.

add_executable(hello_cmake main.cpp) 或者 add_executable(${PROJECT_NAME} main.cpp)

PROJECT_NAME为cmake内置的变量名,代表工程名。

 

转载于:https://www.cnblogs.com/svenzhang9527/p/10703117.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值