-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmkls.txt
More file actions
48 lines (35 loc) · 1.62 KB
/
cmkls.txt
File metadata and controls
48 lines (35 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#cmake最小版本需求
cmake_minimum_required(VERSION xxx)
#设置此项目的名称
project(xxx)
#生成可执行文件target ,后面填写的是生成此可执行文件所依赖的源文件列表。
add_executable(target target_source_codes)
# 设置一个名字var_name 的变量,同时给此变量赋值为var_value
SET(var_name var_value)
# 指定编译器
# CMAKE_C_FLAGS_DEBUG ---- C 编译器
# CMAKE_CXX_FLAGS_DEBUG ---- C++ 编译器
# -std=c++11 使用 C++11
# -g:只是编译器,在编译的时候,产生调试信息。
# -Wall:生成所有警告信息。一下是具体的选项,可以单独使用
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -wall ")
#指定编译类型,debug 或者为 release
# debug 会生成相关调试信息,可以使用 GDB 进行
# release 不会生成调试信息。当无法进行调试时查看此处是否设置为 debug.
set(CMAKE_BUILD_TYPE Debug)
# 打印消息
MESSAGE("MSG")
#给变量var_name赋值为var_value,comment是此变量的注释,和SET 有类似的功效,用于给某变量设置默认值
option(var_name "comment" var_value)
# 添加include路径,也就是头文件路径
include_directories(xxx)
# 调用xxx子目录的CMakeLists.txt执行
add_subdirectory(xxx)
# 给编译器添加xxx参数
add_compile_options(xxx)
# 给编译器添加库目录,
link_directories(xxx)
# 生成库文件,SHARED代表动态库,STATIC代表静态库, 最后一个参数代表此库的源文件列表
add_library(lib_name SHARED or STATIC lib_source_code)
# 给目标添加依赖库
target_link_libraries(target_name lib_name ...)