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