File size: 22,885 Bytes
8e8f337 | 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>CSharpUtilities — CMake 3.27.9 Documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/cmake.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<link rel="shortcut icon" href="../_static/cmake-favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="CTest" href="CTest.html" />
<link rel="prev" title="CPackIFWConfigureFile" href="CPackIFWConfigureFile.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="CTest.html" title="CTest"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="CPackIFWConfigureFile.html" title="CPackIFWConfigureFile"
accesskey="P">previous</a> |</li>
<li>
<img src="../_static/cmake-logo-16.png" alt=""
style="vertical-align: middle; margin-top: -2px" />
</li>
<li>
<a href="https://cmake.org/">CMake</a> »
</li>
<li>
<a href="../index.html">3.27.9 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> »</li>
<li class="nav-item nav-item-this"><a href="">CSharpUtilities</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="csharputilities">
<span id="module:CSharpUtilities"></span><h1>CSharpUtilities<a class="headerlink" href="#csharputilities" title="Permalink to this heading">¶</a></h1>
<div class="versionadded">
<p><span class="versionmodified added">New in version 3.8.</span></p>
</div>
<p>Functions to make configuration of CSharp/.NET targets easier.</p>
<p>A collection of CMake utility functions useful for dealing with CSharp
targets for Visual Studio generators from version 2010 and later.</p>
<p>The following functions are provided by this module:</p>
<p><strong>Main functions</strong></p>
<ul class="simple">
<li><p><span class="target" id="index-0-command:csharp_set_windows_forms_properties"></span><a class="reference internal" href="#command:csharp_set_windows_forms_properties" title="csharp_set_windows_forms_properties"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">csharp_set_windows_forms_properties()</span></code></a></p></li>
<li><p><span class="target" id="index-0-command:csharp_set_designer_cs_properties"></span><a class="reference internal" href="#command:csharp_set_designer_cs_properties" title="csharp_set_designer_cs_properties"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">csharp_set_designer_cs_properties()</span></code></a></p></li>
<li><p><span class="target" id="index-0-command:csharp_set_xaml_cs_properties"></span><a class="reference internal" href="#command:csharp_set_xaml_cs_properties" title="csharp_set_xaml_cs_properties"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">csharp_set_xaml_cs_properties()</span></code></a></p></li>
</ul>
<p><strong>Helper functions</strong></p>
<ul class="simple">
<li><p><span class="target" id="index-0-command:csharp_get_filename_keys"></span><a class="reference internal" href="#command:csharp_get_filename_keys" title="csharp_get_filename_keys"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">csharp_get_filename_keys()</span></code></a></p></li>
<li><p><span class="target" id="index-0-command:csharp_get_filename_key_base"></span><a class="reference internal" href="#command:csharp_get_filename_key_base" title="csharp_get_filename_key_base"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">csharp_get_filename_key_base()</span></code></a></p></li>
<li><p><span class="target" id="index-0-command:csharp_get_dependentupon_name"></span><a class="reference internal" href="#command:csharp_get_dependentupon_name" title="csharp_get_dependentupon_name"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">csharp_get_dependentupon_name()</span></code></a></p></li>
</ul>
<section id="main-functions-provided-by-the-module">
<h2>Main functions provided by the module<a class="headerlink" href="#main-functions-provided-by-the-module" title="Permalink to this heading">¶</a></h2>
<dl class="cmake command">
<dt class="sig sig-object cmake" id="command:csharp_set_windows_forms_properties">
<span class="sig-name descname"><span class="pre">csharp_set_windows_forms_properties</span></span><a class="headerlink" href="#command:csharp_set_windows_forms_properties" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets source file properties for use of Windows Forms. Use this, if your CSharp
target uses Windows Forms:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>csharp_set_windows_forms_properties([<file1> [<file2> [...]]])
</pre></div>
</div>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre"><fileN></span></code></dt><dd><p>List of all source files which are relevant for setting the
<span class="target" id="index-0-prop_sf:VS_CSHARP_<tagname>"></span><a class="reference internal" href="../prop_sf/VS_CSHARP_tagname.html#prop_sf:VS_CSHARP_<tagname>" title="VS_CSHARP_<tagname>"><code class="xref cmake cmake-prop_sf docutils literal notranslate"><span class="pre">VS_CSHARP_<tagname></span></code></a> properties (including <code class="docutils literal notranslate"><span class="pre">.cs</span></code>, <code class="docutils literal notranslate"><span class="pre">.resx</span></code> and
<code class="docutils literal notranslate"><span class="pre">.Designer.cs</span></code> extensions).</p>
</dd>
</dl>
<p>In the list of all given files for all files ending with <code class="docutils literal notranslate"><span class="pre">.Designer.cs</span></code> and
<code class="docutils literal notranslate"><span class="pre">.resx</span></code> is searched. For every <em>designer</em> or <em>resource</em> file a file with the
same base name but only <code class="docutils literal notranslate"><span class="pre">.cs</span></code> as extension is searched. If this is found, the
<span class="target" id="index-1-prop_sf:VS_CSHARP_<tagname>"></span><a class="reference internal" href="../prop_sf/VS_CSHARP_tagname.html#prop_sf:VS_CSHARP_<tagname>" title="VS_CSHARP_<tagname>"><code class="xref cmake cmake-prop_sf docutils literal notranslate"><span class="pre">VS_CSHARP_<tagname></span></code></a> properties are set as follows:</p>
<dl class="simple">
<dt>for the <strong>.cs</strong> file:</dt><dd><ul class="simple">
<li><p>VS_CSHARP_SubType "Form"</p></li>
</ul>
</dd>
<dt>for the <strong>.Designer.cs</strong> file (if it exists):</dt><dd><ul class="simple">
<li><p>VS_CSHARP_DependentUpon <cs-filename></p></li>
<li><p>VS_CSHARP_DesignTime "" (delete tag if previously defined)</p></li>
<li><p>VS_CSHARP_AutoGen ""(delete tag if previously defined)</p></li>
</ul>
</dd>
<dt>for the <strong>.resx</strong> file (if it exists):</dt><dd><ul class="simple">
<li><p>VS_RESOURCE_GENERATOR "" (delete tag if previously defined)</p></li>
<li><p>VS_CSHARP_DependentUpon <cs-filename></p></li>
<li><p>VS_CSHARP_SubType "Designer"</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="cmake command">
<dt class="sig sig-object cmake" id="command:csharp_set_designer_cs_properties">
<span class="sig-name descname"><span class="pre">csharp_set_designer_cs_properties</span></span><a class="headerlink" href="#command:csharp_set_designer_cs_properties" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets source file properties of <code class="docutils literal notranslate"><span class="pre">.Designer.cs</span></code> files depending on
sibling filenames. Use this, if your CSharp target does <strong>not</strong>
use Windows Forms (for Windows Forms use
<span class="target" id="index-1-command:csharp_set_designer_cs_properties"></span><a class="reference internal" href="#command:csharp_set_designer_cs_properties" title="csharp_set_designer_cs_properties"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">csharp_set_designer_cs_properties()</span></code></a> instead):</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>csharp_set_designer_cs_properties([<file1> [<file2> [...]]])
</pre></div>
</div>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre"><fileN></span></code></dt><dd><p>List of all source files which are relevant for setting the
<span class="target" id="index-2-prop_sf:VS_CSHARP_<tagname>"></span><a class="reference internal" href="../prop_sf/VS_CSHARP_tagname.html#prop_sf:VS_CSHARP_<tagname>" title="VS_CSHARP_<tagname>"><code class="xref cmake cmake-prop_sf docutils literal notranslate"><span class="pre">VS_CSHARP_<tagname></span></code></a> properties (including <code class="docutils literal notranslate"><span class="pre">.cs</span></code>,
<code class="docutils literal notranslate"><span class="pre">.resx</span></code>, <code class="docutils literal notranslate"><span class="pre">.settings</span></code> and <code class="docutils literal notranslate"><span class="pre">.Designer.cs</span></code> extensions).</p>
</dd>
</dl>
<p>In the list of all given files for all files ending with
<code class="docutils literal notranslate"><span class="pre">.Designer.cs</span></code> is searched. For every <em>designer</em> file all files
with the same base name but different extensions are searched. If
a match is found, the source file properties of the <em>designer</em> file
are set depending on the extension of the matched file:</p>
<dl class="simple">
<dt>if match is <strong>.resx</strong> file:</dt><dd><ul class="simple">
<li><p>VS_CSHARP_AutoGen "True"</p></li>
<li><p>VS_CSHARP_DesignTime "True"</p></li>
<li><p>VS_CSHARP_DependentUpon <resx-filename></p></li>
</ul>
</dd>
<dt>if match is <strong>.cs</strong> file:</dt><dd><ul class="simple">
<li><p>VS_CSHARP_DependentUpon <cs-filename></p></li>
</ul>
</dd>
<dt>if match is <strong>.settings</strong> file:</dt><dd><ul class="simple">
<li><p>VS_CSHARP_AutoGen "True"</p></li>
<li><p>VS_CSHARP_DesignTimeSharedInput "True"</p></li>
<li><p>VS_CSHARP_DependentUpon <settings-filename></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Because the source file properties of the <code class="docutils literal notranslate"><span class="pre">.Designer.cs</span></code> file are set according
to the found matches and every match sets the <strong>VS_CSHARP_DependentUpon</strong>
property, there should only be one match for each <code class="docutils literal notranslate"><span class="pre">Designer.cs</span></code> file.</p>
</div>
<dl class="cmake command">
<dt class="sig sig-object cmake" id="command:csharp_set_xaml_cs_properties">
<span class="sig-name descname"><span class="pre">csharp_set_xaml_cs_properties</span></span><a class="headerlink" href="#command:csharp_set_xaml_cs_properties" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets source file properties for use of Windows Presentation Foundation (WPF) and
XAML. Use this, if your CSharp target uses WPF/XAML:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>csharp_set_xaml_cs_properties([<file1> [<file2> [...]]])
</pre></div>
</div>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre"><fileN></span></code></dt><dd><p>List of all source files which are relevant for setting the
<span class="target" id="index-3-prop_sf:VS_CSHARP_<tagname>"></span><a class="reference internal" href="../prop_sf/VS_CSHARP_tagname.html#prop_sf:VS_CSHARP_<tagname>" title="VS_CSHARP_<tagname>"><code class="xref cmake cmake-prop_sf docutils literal notranslate"><span class="pre">VS_CSHARP_<tagname></span></code></a> properties (including <code class="docutils literal notranslate"><span class="pre">.cs</span></code>,
<code class="docutils literal notranslate"><span class="pre">.xaml</span></code>, and <code class="docutils literal notranslate"><span class="pre">.xaml.cs</span></code> extensions).</p>
</dd>
</dl>
<p>In the list of all given files for all files ending with
<code class="docutils literal notranslate"><span class="pre">.xaml.cs</span></code> is searched. For every <em>xaml-cs</em> file, a file
with the same base name but extension <code class="docutils literal notranslate"><span class="pre">.xaml</span></code> is searched.
If a match is found, the source file properties of the <code class="docutils literal notranslate"><span class="pre">.xaml.cs</span></code>
file are set:</p>
<blockquote>
<div><ul class="simple">
<li><p>VS_CSHARP_DependentUpon <xaml-filename></p></li>
</ul>
</div></blockquote>
</dd></dl>
</section>
<section id="helper-functions-which-are-used-by-the-above-ones">
<h2>Helper functions which are used by the above ones<a class="headerlink" href="#helper-functions-which-are-used-by-the-above-ones" title="Permalink to this heading">¶</a></h2>
<dl class="cmake command">
<dt class="sig sig-object cmake" id="command:csharp_get_filename_keys">
<span class="sig-name descname"><span class="pre">csharp_get_filename_keys</span></span><a class="headerlink" href="#command:csharp_get_filename_keys" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function which computes a list of key values to identify
source files independently of relative/absolute paths given in cmake
and eliminates case sensitivity:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>csharp_get_filename_keys(OUT [<file1> [<file2> [...]]])
</pre></div>
</div>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">OUT</span></code></dt><dd><p>Name of the variable in which the list of keys is stored</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre"><fileN></span></code></dt><dd><p>filename(s) as given to to CSharp target using <span class="target" id="index-0-command:add_library"></span><a class="reference internal" href="../command/add_library.html#command:add_library" title="add_library"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">add_library()</span></code></a>
or <span class="target" id="index-0-command:add_executable"></span><a class="reference internal" href="../command/add_executable.html#command:add_executable" title="add_executable"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">add_executable()</span></code></a></p>
</dd>
</dl>
<p>In some way the function applies a canonicalization to the source names.
This is necessary to find file matches if the files have been added to
the target with different directory prefixes:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">add_library(</span><span class="nb">lib</span>
<span class="w"> </span><span class="nb">myfile.cs</span>
<span class="w"> </span><span class="o">${</span><span class="nt">CMAKE_CURRENT_SOURCE_DIR</span><span class="o">}</span><span class="na">/myfile.Designer.cs</span><span class="nf">)</span>
<span class="nf">set_source_files_properties(</span><span class="nb">myfile.Designer.cs</span><span class="w"> </span><span class="no">PROPERTIES</span>
<span class="w"> </span><span class="nb">VS_CSHARP_DependentUpon</span><span class="w"> </span><span class="nb">myfile.cs</span><span class="nf">)</span>
<span class="c"># this will fail, because in cmake</span>
<span class="c"># - ${CMAKE_CURRENT_SOURCE_DIR}/myfile.Designer.cs</span>
<span class="c"># - myfile.Designer.cs</span>
<span class="c"># are not the same source file. The source file property is not set.</span>
</pre></div>
</div>
</dd></dl>
<dl class="cmake command">
<dt class="sig sig-object cmake" id="command:csharp_get_filename_key_base">
<span class="sig-name descname"><span class="pre">csharp_get_filename_key_base</span></span><a class="headerlink" href="#command:csharp_get_filename_key_base" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the full filepath and name <strong>without</strong> extension of a key.
KEY is expected to be a key from csharp_get_filename_keys. In BASE
the value of KEY without the file extension is returned:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>csharp_get_filename_key_base(BASE KEY)
</pre></div>
</div>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">BASE</span></code></dt><dd><p>Name of the variable with the computed "base" of <code class="docutils literal notranslate"><span class="pre">KEY</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">KEY</span></code></dt><dd><p>The key of which the base will be computed. Expected to be a
upper case full filename.</p>
</dd>
</dl>
</dd></dl>
<dl class="cmake command">
<dt class="sig sig-object cmake" id="command:csharp_get_dependentupon_name">
<span class="sig-name descname"><span class="pre">csharp_get_dependentupon_name</span></span><a class="headerlink" href="#command:csharp_get_dependentupon_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes a string which can be used as value for the source file property
<span class="target" id="index-4-prop_sf:VS_CSHARP_<tagname>"></span><a class="reference internal" href="../prop_sf/VS_CSHARP_tagname.html#prop_sf:VS_CSHARP_<tagname>" title="VS_CSHARP_<tagname>"><code class="xref cmake cmake-prop_sf docutils literal notranslate"><span class="pre">VS_CSHARP_<tagname></span></code></a> with <em>target</em> being <code class="docutils literal notranslate"><span class="pre">DependentUpon</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>csharp_get_dependentupon_name(NAME FILE)
</pre></div>
</div>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">NAME</span></code></dt><dd><p>Name of the variable with the result value</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">FILE</span></code></dt><dd><p>Filename to convert to <code class="docutils literal notranslate"><span class="pre"><DependentUpon></span></code> value</p>
</dd>
</dl>
<p>Actually this is only the filename without any path given at the moment.</p>
</dd></dl>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">CSharpUtilities</a><ul>
<li><a class="reference internal" href="#main-functions-provided-by-the-module">Main functions provided by the module</a></li>
<li><a class="reference internal" href="#helper-functions-which-are-used-by-the-above-ones">Helper functions which are used by the above ones</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="CPackIFWConfigureFile.html"
title="previous chapter">CPackIFWConfigureFile</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="CTest.html"
title="next chapter">CTest</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/module/CSharpUtilities.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="CTest.html" title="CTest"
>next</a> |</li>
<li class="right" >
<a href="CPackIFWConfigureFile.html" title="CPackIFWConfigureFile"
>previous</a> |</li>
<li>
<img src="../_static/cmake-logo-16.png" alt=""
style="vertical-align: middle; margin-top: -2px" />
</li>
<li>
<a href="https://cmake.org/">CMake</a> »
</li>
<li>
<a href="../index.html">3.27.9 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> »</li>
<li class="nav-item nav-item-this"><a href="">CSharpUtilities</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2000-2023 Kitware, Inc. and Contributors.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.3.0.
</div>
</body>
</html> |