File: highlight.cmake.html

package info (click to toggle)
kf6-syntax-highlighting 6.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 49,060 kB
  • sloc: xml: 203,100; cpp: 12,878; python: 3,055; sh: 965; perl: 814; ruby: 494; pascal: 393; javascript: 161; php: 150; jsp: 132; lisp: 131; haskell: 124; ada: 119; ansic: 107; makefile: 96; f90: 94; ml: 85; cobol: 81; yacc: 71; csh: 62; exp: 61; erlang: 54; sql: 51; java: 47; sed: 45; objc: 37; tcl: 36; awk: 31; asm: 30; fortran: 18; cs: 10
file content (144 lines) | stat: -rw-r--r-- 12,273 bytes parent folder | download | duplicates (2)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.cmake</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (CMake) - Theme (Breeze Light)"/>
</head><body style="background-color:#ffffff;color:#1f1c1b"><pre>
<span style="color:#898887"># This CMakeLists.txt doesn't do anything useful,</span>
<span style="color:#898887"># but it shoudl demonstrate the cmake syntax highlighting</span>
<span style="color:#898887">#</span>
<span style="color:#898887"># Alex Turbov &lt;i.zaufi@gmail.com></span>
<span style="color:#898887">#</span>

<span style="color:#0057ae;background-color:#e0e9f8">#[[.rst:</span>
<span style="color:#898887">Demo</span>
<span style="color:#898887">----</span>

<span style="color:#898887">This is an </span><span style="font-weight:bold">**RST**</span><span style="color:#898887"> documentation.</span>

<span style="color:#0057ae">::</span>

<span style="color:#0057ae">    # Sample code block</span>
<span style="color:#0057ae">    blah-blah</span>

<span style="color:#898887">But we are about to test CMake here ;-)</span>

<span style="color:#0057ae;background-color:#e0e9f8">#]]</span>

<span style="font-weight:bold">cmake_policy</span>(<span style="color:#006e28">VERSION</span> <span style="color:#0057ae">3.11</span>)

<span style="font-weight:bold">project</span>(
    Demo <span style="color:#006e28">VERSION</span> <span style="color:#0057ae">1.0</span>
    <span style="color:#006e28">DESCRIPTION</span> <span style="color:#bf0303">"For unit testing purposes"</span>
    <span style="color:#898887"># </span><span style="color:#81ca2d;background-color:#f7e6e6;font-weight:bold">NOTE</span><span style="color:#898887"> that particular languages is a separate style</span>
    <span style="color:#898887"># to highlight "special" (well known values)</span>
    <span style="color:#006e28">LANGUAGES</span> <span style="color:#006e28">C</span> <span style="color:#006e28">CXX</span>
  )

<span style="font-weight:bold">set</span>(SOME_TRUE_OPTION <span style="color:#30a030">TRUE</span>)      <span style="color:#898887"># `true` value</span>
<span style="color:#898887"># `false` value and "internal" variable</span>
<span style="font-weight:bold">set</span>(<span style="color:#0057ae">_ANOTHER_FALSE_OPTION</span> <span style="color:#e05050">OFF</span> <span style="color:#006e28">CACHE</span> <span style="color:#006e28">INTERNAL</span> <span style="color:#bf0303">"Internal option"</span>)

<span style="color:#898887">#BEGIN Message block</span>
<span style="font-weight:bold">message</span>(<span style="color:#006e28">FATAL_ERROR</span> <span style="color:#bf0303">"Ordinal message do </span><span style="color:#b08000">${VARIABLE_EXPANSION}</span><span style="color:#bf0303">"</span>)
<span style="font-weight:bold">message</span>(<span style="color:#006e28">AUTHOR_WARNING</span> <span style="color:#bf0303">"... standard variables have a dedicated style"</span>)
<span style="font-weight:bold">message</span>(<span style="color:#006e28">SEND_ERROR</span> <span style="color:#bf0303">"e.g. </span><span style="color:#b08000">${</span><span style="color:#c09050">PROJECT_DESCRIPTION</span><span style="color:#b08000">}</span><span style="color:#bf0303"> or </span><span style="color:#b08000">${</span><span style="color:#c09050">CMAKE_COMMAND</span><span style="color:#b08000">}</span><span style="color:#bf0303">"</span>)
<span style="font-weight:bold">message</span>(
    <span style="color:#006e28">STATUS</span> <span style="color:#bf0303">[=[</span>
<span style="color:#bf0303">        Raw messages do not do ${VARIABLES_EXPANSION} or \n</span>
<span style="color:#bf0303">        escape symbols highlighting...</span>
<span style="color:#bf0303">    ]=]</span>
)
<span style="color:#898887">#END Message block</span>

<span style="color:#898887"># </span><span style="color:#e85848;background-color:#451e1a;font-weight:bold">ATTENTION</span><span style="color:#898887"> Every command highlight only its own named keywords...</span>
<span style="color:#898887"># Also, note aliased (most of the time imported) targets higlighted as well</span>
<span style="font-weight:bold">add_library</span>(<span style="color:#b08000">Foo::foo</span> <span style="color:#006e28">IMPORTED</span> <span style="color:#006e28">GLOBAL</span>)
<span style="font-weight:bold">set</span>(KW_HL IMPORTED GLOBAL)      <span style="color:#898887"># `IMPORTED` and `GLOBAL` are not highlighted here!</span>

<span style="color:#898887"># Properties are separate ("special value") style</span>
<span style="font-weight:bold">set_target_properties</span>(<span style="color:#b08000">Foo::foo</span> <span style="color:#006e28">PROPERTIES</span> <span style="color:#006e28">LOCATION</span> <span style="color:#bf0303">"</span><span style="color:#b08000">${FOO_LIBRARY}</span><span style="color:#bf0303">"</span>)

<span style="color:#898887"># Generator expressions</span>
<span style="font-weight:bold">target_compile_definitions</span>(
    <span style="color:#898887"># </span><span style="color:#81ca2d;background-color:#f7e6e6;font-weight:bold">NOTE</span><span style="color:#898887"> Ok w/ CMake >= 3.11</span>
    <span style="color:#b08000">Foo::foo</span>
    <span style="color:#b86050">$&lt;$&lt;</span><span style="color:#b84040;font-weight:bold">PLATFORM_ID</span><span style="color:#b86050">:Windows>:WINDOWS_FOO></span>
    <span style="color:#b86050">$&lt;$&lt;</span><span style="color:#b84040;font-weight:bold">PLATFORM_ID</span><span style="color:#b86050">:Linux>:</span>
<span style="color:#b86050">        LINUX_FOO</span>
<span style="color:#b86050">        $&lt;$&lt;</span><span style="color:#b84040;font-weight:bold">BOOL</span><span style="color:#b86050">:</span><span style="color:#b08000">${</span><span style="color:#0057ae">_has_foo</span><span style="color:#b08000">}</span><span style="color:#b86050">>:SOME_FOO_PATH=</span><span style="color:#b08000">${</span><span style="color:#c09050">PROJECT_BINARY_DIR</span><span style="color:#b08000">}</span><span style="color:#b86050">/foo></span>
<span style="color:#b86050">    ></span>
  )

<span style="color:#0057ae;background-color:#e0e9f8">#[=======================================================================[.rst:</span>
<span style="color:#0057ae">.. cmake:command:: </span><span style="color:#898887">my_fun</span>

<span style="font-style:italic">*RST*</span><span style="color:#898887"> documentation </span><span style="color:#0057ae">``can``</span><span style="color:#898887"> refer to </span><span style="font-weight:bold">:cmake:command:</span><span style="color:#b08000">`any_commands`</span><span style="color:#898887"> or</span>
<span style="font-weight:bold">:cmake:variable:</span><span style="color:#b08000">`variables`</span><span style="color:#898887">...</span>

<span style="color:#0057ae">.. code-block:: cmake</span>
<span style="color:#0057ae">   :caption: **Synopsys**</span>

<span style="color:#0057ae">    my_fun([ANYTHING...])</span>

<span style="color:#0057ae;background-color:#e0e9f8">#]=======================================================================]</span>
<span style="font-weight:bold">function</span>(my_fun)
    <span style="color:#898887"># </span><span style="color:#ca9219;background-color:#451e1a;font-weight:bold">TODO</span><span style="color:#898887"> Add implementation</span>
<span style="font-weight:bold">endfunction</span>()

<span style="color:#644a9b">my_fun</span>(
    <span style="color:#898887"># Custom functions do not highlight "standard" named args ...</span>
    PUBLIC LOCATION PARENT_SCOPE
    <span style="color:#898887"># only some well-known values ...</span>
    <span style="color:#e05050">smth-NOTFOUND</span> <span style="color:#30a030">ON</span>
    <span style="color:#898887"># and standard variables</span>
    <span style="color:#c09050">PROJECT_VERSION</span>
    <span style="color:#898887"># or substitutions</span>
    <span style="color:#b08000">$ENV{HOME}</span> OR <span style="color:#b08000">${</span><span style="color:#0057ae">_internal_var_is_grey</span><span style="color:#b08000">}</span>
  )

<span style="color:#898887"># I dont'recall exactly, but there was some bug with `if`...</span>
<span style="font-weight:bold">if</span>((A <span style="color:#006e28">AND</span> <span style="color:#bf0303">"</span><span style="color:#b08000">${B}</span><span style="color:#bf0303">"</span>) <span style="color:#006e28">OR</span> C <span style="color:#006e28">OR</span> (var <span style="color:#006e28">MATCHES</span> <span style="color:#bf0303">"regex"</span>))
    <span style="color:#898887"># Anyway... it is Ok nowadays ;-)</span>

<span style="font-weight:bold">elseif</span>(<span style="color:#006e28">POLICY</span> CMP066)
    <span style="font-weight:bold">add_executable</span>(<span style="color:#b08000">${</span><span style="color:#c09050">PROJECT_NAME</span><span style="color:#b08000">}</span> <span style="color:#b08000">${</span><span style="color:#c09050">PROJECT_NAME</span><span style="color:#b08000">}</span><span style="color:#b08000">.cc</span>)
    <span style="font-weight:bold">target_link_libraries</span>(
        <span style="color:#b08000">${</span><span style="color:#c09050">PROJECT_NAME</span><span style="color:#b08000">}</span>
        <span style="color:#b08000">PRIVATE</span>
            <span style="color:#b08000">Qt5::Core</span>
            <span style="color:#b86050">$&lt;$&lt;</span><span style="color:#b84040;font-weight:bold">BOOL</span><span style="color:#b86050">:</span><span style="color:#b08000">${HAS_FOO}</span><span style="color:#b86050">>:</span><span style="color:#b08000">Foo::foo</span><span style="color:#b86050">></span>
      )

<span style="font-weight:bold">endif</span>()

<span style="color:#898887"># In each function call below, all 3 named parameter lines should apply the same highlighting.</span>
<span style="font-weight:bold">add_custom_command</span>(
    <span style="color:#006e28">COMMAND</span> <span style="color:#30a030">true</span>
    <span style="color:#006e28">COMMAND</span> (<span style="color:#30a030">true</span>)
    <span style="color:#006e28">COMMAND</span> <span style="color:#30a030">true</span>
)
<span style="font-weight:bold">add_custom_target</span>(<span style="color:#b08000">TargetName</span>
    <span style="color:#006e28">WORKING_DIRECTORY</span> somedir
    <span style="color:#006e28">COMMAND</span> (<span style="color:#30a030">true</span>)
    <span style="color:#006e28">BYPRODUCTS</span> somefile
)
<span style="font-weight:bold">execute_process</span>(
    <span style="color:#006e28">COMMAND</span> <span style="color:#30a030">true</span>
    <span style="color:#006e28">COMMAND</span> (<span style="color:#30a030">true</span>)
    <span style="color:#006e28">COMMAND</span> <span style="color:#30a030">true</span>
)
<span style="font-weight:bold">add_test</span>(
    <span style="color:#006e28">NAME</span> sometest
    <span style="color:#006e28">COMMAND</span> (<span style="color:#30a030">true</span>)
    <span style="color:#006e28">WORKING_DIRECTORY</span> somedir
)

<span style="color:#898887"># nested parentheses</span>
<span style="font-weight:bold">if</span>( <span style="color:#30a030">true</span> <span style="color:#006e28">AND</span> ( <span style="color:#e05050">false</span> <span style="color:#006e28">OR</span> (<span style="color:#bf0303">"</span><span style="color:#b08000">${</span><span style="color:#c09050">CMAKE_CXX_COMPILER_ID</span><span style="color:#b08000">}</span><span style="color:#bf0303">"</span> <span style="color:#006e28">STREQUAL</span> <span style="color:#bf0303">"Clang"</span>) ) )
<span style="font-weight:bold">endif</span>()

<span style="font-weight:bold">if</span>(<span style="color:#006e28">NOT</span> <span style="color:#006e28">TARGET</span> <span style="color:#b08000">Boost</span>::<span style="color:#b08000">${lib}</span>)
    <span style="font-weight:bold">add_library</span>(<span style="color:#b08000">Boost</span>::<span style="color:#b08000">${lib}</span> <span style="color:#006e28">INTERFACE</span> <span style="color:#006e28">IMPORTED</span>)
<span style="font-weight:bold">endif</span>()
</pre></body></html>