aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/snippets/cmake.xml
blob: 96b1d563ac6aa8c8739a04042f54972604914c37 (plain)
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
<?xml version="1.0" encoding="UTF-8"?>
<snippets>
    <snippet group="CMake" trigger="print_properties" id="cmake_print_properties" complement="">include(CMakePrintHelpers)
cmake_print_properties(TARGETS $targets$ PROPERTIES $properties$)</snippet>
    <snippet group="CMake" trigger="print_variables" id="cmake_print_variables" complement="">include(CMakePrintHelpers)
cmake_print_variables($variables$)</snippet>
    <snippet group="CMake" trigger="qt6_console_app" id="cmake_qt6_console_app" complement=""># https://doc.qt.io/qt-6/cmake-get-started.html
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Core)
qt_standard_project_setup()

qt_add_executable($executable$
    main.cpp
)

target_link_libraries($executable$ PRIVATE Qt6::Core)</snippet>
    <snippet group="CMake" trigger="qt6_gui_app" id="cmake_qt6_gui_app" complement=""># https://doc.qt.io/qt-6/cmake-get-started.html
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Widgets)
qt_standard_project_setup()

qt_add_executable($executable$
    mainwindow.ui
    mainwindow.cpp
    main.cpp
)

target_link_libraries($executable$ PRIVATE Qt6::Widgets)

set_target_properties($executable$ PROPERTIES
    WIN32_EXECUTABLE ON
    MACOSX_BUNDLE ON
)</snippet>
  <snippet group="CMake" trigger="sample_find_module" id="cmake_sample_find_module" complement=""># https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#a-sample-find-module

#[=======================================================================[.rst:
Find$package$
-------

Finds the $package$ library.

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``$package$::$package$``
  The $package$ library

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables:

``$package$_FOUND``
  True if the system has the $package$ library.
``$package$_VERSION``
  The version of the $package$ library which was found.
``$package$_INCLUDE_DIRS``
  Include directories needed to use $package$.
``$package$_LIBRARIES``
  Libraries needed to link to $package$.

Cache Variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``$package$_INCLUDE_DIR``
  The directory containing ``$header$.h``.
``$package$_LIBRARY``
  The path to the $library$ library.

#]=======================================================================]

find_package(PkgConfig)
pkg_check_modules(PC_$package$ QUIET $package$)

find_path($package$_INCLUDE_DIR
  NAMES $header$.h
  PATHS \\${PC_$package$_INCLUDE_DIRS}
  PATH_SUFFIXES $package$
)

find_library($package$_LIBRARY
  NAMES $library$
  PATHS \\${PC_$package$_LIBRARY_DIRS}
)

set($package$_VERSION \\${PC_$package$_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args($package$
  FOUND_VAR $package$_FOUND
  REQUIRED_VARS
    $package$_LIBRARY
    $package$_INCLUDE_DIR
  VERSION_VAR $package$_VERSION
)

if($package$_FOUND)
  set($package$_LIBRARIES \\${$package$_LIBRARY})
  set($package$_INCLUDE_DIRS \\${$package$_INCLUDE_DIR})
endif()

if($package$_FOUND AND NOT TARGET $package$::$package$)
  add_library($package$::$package$ UNKNOWN IMPORTED)
  set_target_properties($package$::$package$ PROPERTIES
    IMPORTED_LOCATION "\\${$package$_LIBRARY}"
    INTERFACE_COMPILE_OPTIONS "\\${PC_$package$_CFLAGS_OTHER}"
    INTERFACE_INCLUDE_DIRECTORIES "\\${$package$_INCLUDE_DIR}"
  )
endif()

mark_as_advanced(
  $package$_INCLUDE_DIR
  $package$_LIBRARY
)</snippet>
</snippets>