]> git.rmz.io Git - dotfiles.git/blob - vim/ultisnips/cmake.snippets
vim: don't set viminfo in nvim
[dotfiles.git] / vim / ultisnips / cmake.snippets
1 snippet cmake "CMakeFiles Stub" b
2 cmake_minimum_required(VERSION 3.12)
3 project(${1:ProjectName})
4
5 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6
7 # find_package(Boost REQUIRED)
8
9 add_executable(${2:$1}
10 ${3:main.cpp}
11 )
12
13 set_target_properties($2
14 PROPERTIES CXX_STANDARD 14
15 )
16
17 target_link_libraries($2
18 )
19 endsnippet
20
21 snippet pprint "Pretty print variables" b
22 include(CMakePrintHelpers)
23 cmake_print_variables(${1:var1})
24 endsnippet
25
26 snippet qt5 "Find Qt5 Modules" b
27 # Qt5 Modules
28 set(qt5_modules
29 Qt5Core
30 Qt5Gui
31 Qt5Widgets
32 )
33
34 foreach(qt5_module ${qt5_modules})
35 find_package(${qt5_module} REQUIRED)
36 endforeach()
37 endsnippet
38
39 snippet include
40 include_directories(
41 ${${0:INCLUDE_DIR}}
42 )
43 endsnippet
44
45 snippet find
46 find_package(${0:LIBRARY})
47 endsnippet
48
49 snippet glob
50 file(GLOB ${1:SRCS} *.${0:cpp})
51 endsnippet
52
53 snippet subdir
54 add_subdirectory(${0:src})
55 endsnippet
56
57 snippet lib
58 add_library(${1:lib}
59 ${${0:SRCS}}
60 )
61 endsnippet
62
63 snippet link
64 target_link_libraries(\${PROJECT_NAME}
65 ${0:somelib}
66 )
67 endsnippet
68
69 snippet bin
70 add_executable(${1:bin})
71 endsnippet
72
73 snippet set
74 set(${1:var} ${0:val})
75 endsnippet
76
77 snippet dep
78 add_dependencies(${1:target}
79 ${0:dep}
80 )
81 endsnippet
82
83 snippet props
84 set_target_properties(${1:target} ${2:PROPERTIES}
85 ${3:COMPILE_FLAGS} ${0:"-O3 -Wall -pedantic"}
86 )
87 endsnippet
88
89 snippet debug_targets "Debug targets" b
90 set(CMAKE_DEBUG_TARGET_PROPERTIES
91 INCLUDE_DIRECTORIES
92 COMPILE_DEFINITIONS
93 COMPILE_OPTIONS
94 COMPILE_FEATURES
95 AUTOUIC_OPTIONS
96 SOURCES
97 POSITION_INDEPENDENT_CODE
98 )
99 endsnippet
100
101 snippet FPP "FPP Copyright" b
102 # Copyright © Focal Point Positioning Limited `!v strftime("%Y")`. All Rights Reserved.
103 # This code is the copyright of Focal Point Positioning Limited and
104 # cannot be used, copied or distributed without the express written
105 # permission of Focal Point Positioning Limited.
106 ${0}
107 endsnippet
108
109 snippet FetchContent_url "FetchContent" b
110 FetchContent_Declare(${1:name}
111 URL ${2:https://example.com/project.tar.gz}
112 )
113 FetchContent_MakeAvailable(${1/\w+/\L$0\E/})
114 endsnippet
115
116 snippet FetchContent_git "FetchContent" b
117 FetchContent_Declare(${1:name}
118 GIT_REPOSITORY ${2:https://github.com/${3:user/repo}}
119 )
120 FetchContent_MakeAvailable(${1/\w+/\L$0\E/})
121 endsnippet