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