Skip to content

Commit 827b018

Browse files
committedJan 5, 2023
add CMakeLists-模板.txt
1 parent 3dccc4d commit 827b018

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
 

‎002_cmake_demo/CMakeLists-模板.txt

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# cmake最小版本要求3.21.0
2+
cmake_minimum_required(VERSION 3.21.0)
3+
4+
# 指定project名称为client
5+
project(client)
6+
7+
# set 定义变量
8+
set(PROJ_VERSION v1.0.0)
9+
10+
set(CMAKE_CXX_STANDARD 17)
11+
# 设置编译器编译模式
12+
set(cmake_build_type "Debug")
13+
14+
# include 指令用来载入并运行来自于文件或模块的 CMake 代码
15+
#include()
16+
17+
# 将/usr/include/myincludefolder 和./include添加到头文件搜索路径
18+
#include_directories(/usr/include/myincludefolder ./include)
19+
include_directories(include)
20+
21+
# 将/usr/lib/myincludefolder ./lib添加到库文件搜索路径
22+
#link_directories(/usr/lib/myincludefolder ./lib)
23+
24+
# 设置源文件path
25+
aux_source_directory(src DIR_SRCS)
26+
#aux_source_directory(src/entity DIR_ENTITY)
27+
#source_group(src src/entity)
28+
29+
# 生成共享库,这儿不需要.hpp
30+
#add_library(calculate SHARED hello.cpp)
31+
32+
#添加编译参数 -Wall -std=c++11
33+
add_compile_options(-Wall -std=c++17 -o2)
34+
35+
# 链接共享库,将calculate.so动态库链接到可执行文件main
36+
#target_link_libraries(main calculate)
37+
38+
39+
# 添加需要的所有的执行文件
40+
add_executable(client ${DIR_SRCS})
41+
42+
# ---------------CMake常用变量----------------
43+
# CMAKE_C_FLAGS #gcc编译选项
44+
# CMAKE_CXX_FLAGS #g++编译选项
45+
# set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") #这表明不会覆盖CMAKE_CXX_FLAGS,而是在它后面追加-std=c++11这个编译选项
46+
#
47+
##设定编译类型为debug,调试时需要选择debug
48+
# set(CMAEK_BUILE_TYPE Debug)
49+
##设定编译类型为release,发布时需要选择release
50+
# set(CMAKE_BUILE_TYPE Release)
51+
#
52+
# CMAKE_BINARY_DIR
53+
# CMAKE_SOURCE_DIR #指定CMakeList.txt所在的路径
54+
# CMAKE_C_COMPILER #指定C编译器
55+
# CMAKE_CXX_COMPILER #指定C++编译器
56+
# EXECUTABLE_OUTPUT_PATH #可执行文件输出的存放路径
57+
# LIBRARY_OUTPUT_PATH #库文件输出的存放路径

0 commit comments

Comments
 (0)
Please sign in to comment.