]> git.rmz.io Git - dotfiles.git/blobdiff - vim/ultisnips/cmake.snippets
vim: configure comments for taskrc files
[dotfiles.git] / vim / ultisnips / cmake.snippets
index afdbef690375d0db7836baede087166ce73c87b6..e773a95c8cb097e88074f37845b73799b8324b03 100644 (file)
@@ -1,24 +1,23 @@
 snippet cmake "CMakeFiles Stub" b
-cmake_minimum_required(VERSION 2.8.11)
+cmake_minimum_required(VERSION `cmake --version | grep -Po '\d+\.\d+'`)
 project(${1:ProjectName})
 
-find_package(${2:LIBRARY})
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
+set(CMAKE_C_STANDARD 17)
+set(CMAKE_C_STANDARD_REQUIRED TRUE)
 
-include_directories(
-       ${$2_INCLUDE_DIR}
+add_executable(${2:$1}
+       ${3:main.cpp}
 )
 
-add_subdirectory(${0:src})
-
-add_executable($1)
-set_target_properties($1
-       PROPERTIES CXX_STANDARD 11
+target_link_libraries($2
 )
+endsnippet
 
-
-target_link_libraries($1
-       ${$2_LIBRARIES}
-)
+snippet pprint "Pretty print variables" b
+include(CMakePrintHelpers)
+cmake_print_variables(${1:var1})
 endsnippet
 
 snippet qt5 "Find Qt5 Modules" b
@@ -30,13 +29,7 @@ set(qt5_modules
 )
 
 foreach(qt5_module ${qt5_modules})
-       find_package(${qt5_module} QUIET)
-       if(${qt5_module}_FOUND)
-       
-       else(${qt5_module}_FOUND)
-               message(FATAL_ERROR "Qt5 module '${qt5_module}' not found")
-       endif()
-       endif()
+       find_package(${qt5_module} REQUIRED)
 endforeach()
 endsnippet
 
@@ -48,8 +41,6 @@ endsnippet
 
 snippet find
 find_package(${0:LIBRARY})
-include_dir($0_INCLUDE_DIRS)
-link_directories($0_LIBRARY_DIRS)
 endsnippet
 
 snippet glob
@@ -61,19 +52,33 @@ add_subdirectory(${0:src})
 endsnippet
 
 snippet lib
-add_library(${1:lib} ${2:STATIC}
-       ${${0:SRCS}}
+add_library(${1:lib})
+add_library(\${PROJECT_NAME}::$1 ALIAS $1)
+target_sources($1 PRIVATE
+       $2
+)
+target_link_libraries($1
+       PUBLIC
+               $3
+       PRIVATE
+               $4
 )
 endsnippet
 
 snippet link
-target_link_libraries(${1:bin}
+target_link_libraries(\${PROJECT_NAME}
        ${0:somelib}
 )
 endsnippet
 
 snippet bin
 add_executable(${1:bin})
+target_sources($1 PRIVATE
+       $2
+)
+target_link_libraries($1 PRIVATE
+       $3
+)
 endsnippet
 
 snippet set
@@ -87,8 +92,41 @@ add_dependencies(${1:target}
 endsnippet
 
 snippet props
-set_target_properties(${1:target}
-       ${2:PROPERTIES} ${3:COMPILE_FLAGS}
-       ${0:"-O3 -Wall -pedantic"}
+set_target_properties(${1:target} ${2:PROPERTIES}
+       ${3:COMPILE_FLAGS} ${0:"-O3 -Wall -pedantic"}
+)
+endsnippet
+
+snippet debug_targets "Debug targets" b
+set(CMAKE_DEBUG_TARGET_PROPERTIES
+       INCLUDE_DIRECTORIES
+       COMPILE_DEFINITIONS
+       COMPILE_OPTIONS
+       COMPILE_FEATURES
+       AUTOUIC_OPTIONS
+       SOURCES
+       POSITION_INDEPENDENT_CODE
+)
+endsnippet
+
+snippet FPP "FPP Copyright" b
+# Copyright © Focal Point Positioning Limited `!v strftime("%Y")`. All Rights Reserved.
+# This code is the copyright of Focal Point Positioning Limited and
+# cannot be used, copied or distributed without the express written
+# permission of Focal Point Positioning Limited.
+${0}
+endsnippet
+
+snippet FetchContent_url "FetchContent" b
+FetchContent_Declare(${1:name}
+       URL ${2:https://example.com/project.tar.gz}
+)
+FetchContent_MakeAvailable(${1/\w+/\L$0\E/})
+endsnippet
+
+snippet FetchContent_git "FetchContent" b
+FetchContent_Declare(${1:name}
+       GIT_REPOSITORY ${2:https://github.com/${3:user/repo}}
 )
+FetchContent_MakeAvailable(${1/\w+/\L$0\E/})
 endsnippet