forked from rafamadriz/friendly-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmake.json
256 lines (256 loc) · 6.29 KB
/
cmake.json
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{
"Init cmake": {
"prefix": "cmi",
"body": [
"cmake_minimum_required(VERSION ${1:3.16})",
"project(${2:myProject})",
"",
"if(NOT CMAKE_BUILD_TYPE)",
"\tset(default_build_type \"Debug\")",
"\tmessage(STATUS \"Set the build type to `\\${default_build_type}` as none was specified.\")",
"\tset(CMAKE_BUILD_TYPE \\${default_build_type} CACHE STRING \"Chooce the build type.\" FORCE)",
"\tset_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS",
"\t\"Debug\" \"Release\" \"MinSizeRel\" \"RelWithDebInfo\")",
"endif()",
"message(STATUS \"$2 Build Type: \\${CMAKE_BUILD_TYPE}\")",
"",
"# Set the version for $2",
"set($2_Version_Major ${3:0})",
"set($2_Version_Minor ${4:1})",
"set($2_Version_Patch ${5:0})",
"set($2_Version_Status \"${6:-dev}\")",
"set(${7:PROJECT_VERSION}",
"\t\"\\${$2_Version_Major}.\\${$2_Version_Minor}.\\${$2_Version_Patch}\\${$2_Version_Status}\"",
")",
"message(STATUS \"\\${PROJECT_NAME} version: \\${PROJECT_VERSION}\")"
],
"description": "Init 'CMakeLists.txt'."
},
"project()": {
"prefix": "prj",
"body":[
"project(${1:myProject})$2"
],
"description": "Add the snippet for project()"
},
"cmake_minimum_required()": {
"prefix": "cmr",
"body": [
"cmake_minimum_required(VERSION ${1:3.16})$2"
],
"description": "Add the snippet for cmake_minimum_required()"
},
"message()": {
"prefix": "msg",
"body": [
"message(${1|STATUS,DEBUG,WARNING,SEND_ERROR,FATAL_ERROR|} \"${2:message}\")$3"
],
"description": "Add the snippet for message()"
},
"export compile commands": {
"prefix": "ecc",
"body": [
"set(CMAKE_EXPORT_COMPILE_COMMANDS ON)"
],
"description": "Add the snippet to generate 'compile_commands.json'"
},
"set a variable": {
"prefix": "sv",
"body": [
"set(${1:variable} ${2:0})$3"
],
"description": "Add the snippet to use set() for defining a variable"
},
"set variable cache": {
"prefix": "sc",
"body": [
"set(${1:variable} ${2:value} CACHE ${3|BOOL,FILEPATH,PATH,STRING|} \"${4:message} FORCE)$5"
],
"description": "Add the snippet set() for cache entry"
},
"option()": {
"prefix": "opt",
"body": [
"option(${1:variable} \"${2:message}\" ${3|ON,OFF|})"
],
"description": "Add the snippet for option()"
},
"aux_source_directory": {
"prefix": "aux",
"body": [
"aux_source_directory(${1:./} ${2:SOURCES})"
],
"description": "Add the snippet for aux_source_directory()"
},
"add_subdirectory()": {
"prefix": "ads",
"body": [
"add_subdirectory(${1:./src})"
],
"description": "Add the snippet for add_subdirectory()"
},
"add_executable()": {
"prefix": "exe",
"body": [
"add_executable(",
"\t${1:exe}",
"\t${2:\\${SOURCES\\}}",
")"
],
"description": "Add the snippet add_executable() to build source files as an exeutable file"
},
"add_library()": {
"prefix": "lib",
"body": [
"add_library(",
"\t${1:myLib}",
"\t${2|STATIC,SHARED,MODULE|}",
"\t${3:\\${SOURCES\\}}",
")"
],
"description": "Add the snippet add_library() to build source files as a library"
},
"target_link_libraries()": {
"prefix": "tll",
"body": [
"target_link_libraries(",
"\t${1:myTarget}",
"\t${2:myLib}",
")"
],
"description": "Add the snippet target_link_libraries() to link libraries"
},
"target_include_directories()": {
"prefix": "tid",
"body": [
"target_include_directories(",
"\t${1:myTarget}",
"\t${2|PUBLIC,INTERFACE,PRIVATE|} ${3:\\${PROJECT_SOURCE_DIR\\}/includes}",
")"
],
"description": "Add the snippet target_include_directories() to set the include directories for target"
},
"include_directories()": {
"prefix": "i_d",
"body": [
"include_directories(${1:\\${PROJECT_SOURCE_DIR\\}})"
],
"description": "Add the snippet include_directories() to set include directories"
},
"find_package()": {
"prefix": "f_p",
"body": [
"find_package(${1:OpenCV} REQUIRED)"
],
"description": "Add the snippet find_package()"
},
"if() ... endif()": {
"prefix": "if",
"body": [
"if(${1:condition})",
"\t${2:commands}",
"endif()"
],
"description": "Add the snippet if()"
},
"else if()": {
"prefix": "elif",
"body": [
"elseif(${1:condition})",
"\t${2:commands}"
],
"description": "Add the snippet 'elseif()'"
},
"else()": {
"prefix": "else",
"body": [
"else()",
"\t${1:commands}"
],
"description": "Add the snippet else()"
},
"if() ... else() ... endif()":{
"prefix": "ife",
"body": [
"if(${1:condition})",
"\t${2:command1}",
"else()",
"\t${3:command2}",
"endif()"
],
"description": "Add the snippet 'if() ... else() ... endif()'"
},
"configure_file": {
"prefix": "conf",
"body": [
"configure_file(",
"\t${1:\\${PROJECT_SOURCE_DIR\\}/includes/version.h.in}",
"\t${2:\\${PROJECT_SOURCE_DIR\\}/includes/version.h}",
"\t@ONLY",
")"
],
"description": "Add the snippet for configure_file()"
},
"include()": {
"prefix": "inc",
"body": [
"include(${1:FetchContent})"
],
"description": "Add the snippet for include()"
},
"FetchContent_Declare()": {
"prefix": "Fet",
"body": [
"include(FetchContent)",
"FetchContent_Declare(",
"\t${1:repo_name}",
"\tGIT_REPOSITORY ${2:repo_url}",
"\tGIT_TAG ${3:tag}",
")",
"FetchContent_MakeAvailable($1)"
],
"description": "Add the snippet for FetchContent_Declare()"
},
"Use googletest": {
"prefix": "gtest",
"body": [
"include(FetchContent)",
"set(gtest_force_shared_crt ON CACHE BOOL \"\" FORCE)",
"set(INSTALL_GTEST OFF CACHE BOOL \"\" FORCE)",
"FetchContent_Declare(",
"\tgoogletest",
"\tGIT_REPOSITORY https://github.com/google/googletest.git",
"\tGIT_TAG ${1:v1.14.0}",
")",
"FetchContent_MakeAvailable(googletest)"
],
"description": "Add the snippet to use gtest"
},
"Set c++ standard": {
"prefix": "cxx",
"body": [
"set(CMAKE_CXX_STANDDARD ${1:14})",
"set(CMAKE_CXX_STANDDARD_REQUIRED ON)"
],
"description": "Add the snippet to set c++ standard"
},
"install()": {
"prefix": "inst",
"body": [
"install(",
"\t${1|FILES,TARGETS|} ${2:source_files}",
"\tDESTINATION ${3:target_path}",
")"
],
"description": "Add the snippet for install()"
},
"add_test()": {
"prefix": "adt",
"body": [
"add_test(",
"\t${1:test_myTest} ${1}",
")"
],
"description": "Add the snippet for add_test()"
}
}