您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页cmake-hello

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

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务