<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>CSharpUtilities — CMake 3.23.1 Documentation</title> | |
<link rel="stylesheet" href="../_static/cmake.css" type="text/css" /> | |
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> | |
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> | |
<script type="text/javascript" src="../_static/jquery.js"></script> | |
<script type="text/javascript" src="../_static/underscore.js"></script> | |
<script type="text/javascript" src="../_static/doctools.js"></script> | |
<script type="text/javascript" src="../_static/language_data.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.23.1 Documentation</a> » | |
</li> | |
<li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> »</li> | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
<div class="body" role="main"> | |
<div class="section" id="csharputilities"> | |
<span id="module:CSharpUtilities"></span><h1>CSharpUtilities<a class="headerlink" href="#csharputilities" title="Permalink to this headline">¶</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> | |
<div class="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 headline">¶</a></h2> | |
<dl class="command"> | |
<dt id="command:csharp_set_windows_forms_properties"> | |
<code class="sig-name descname">csharp_set_windows_forms_properties</code><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="command"> | |
<dt id="command:csharp_set_designer_cs_properties"> | |
<code class="sig-name descname">csharp_set_designer_cs_properties</code><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="command"> | |
<dt id="command:csharp_set_xaml_cs_properties"> | |
<code class="sig-name descname">csharp_set_xaml_cs_properties</code><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> | |
</div> | |
<div class="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 headline">¶</a></h2> | |
<dl class="command"> | |
<dt id="command:csharp_get_filename_keys"> | |
<code class="sig-name descname">csharp_get_filename_keys</code><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="w"> </span><span class="nb">myfile.cs</span><span class="w"></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="w"></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="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="w"></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="command"> | |
<dt id="command:csharp_get_filename_key_base"> | |
<code class="sig-name descname">csharp_get_filename_key_base</code><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="command"> | |
<dt id="command:csharp_get_dependentupon_name"> | |
<code class="sig-name descname">csharp_get_dependentupon_name</code><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> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="sphinxsidebar" role="navigation" aria-label="main navigation"> | |
<div class="sphinxsidebarwrapper"> | |
<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> | |
<h4>Previous topic</h4> | |
<p class="topless"><a href="CPackIFWConfigureFile.html" | |
title="previous chapter">CPackIFWConfigureFile</a></p> | |
<h4>Next topic</h4> | |
<p class="topless"><a href="CTest.html" | |
title="next chapter">CTest</a></p> | |
<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" /> | |
<input type="submit" value="Go" /> | |
</form> | |
</div> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</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.23.1 Documentation</a> » | |
</li> | |
<li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> »</li> | |
</ul> | |
</div> | |
<div class="footer" role="contentinfo"> | |
© Copyright 2000-2022 Kitware, Inc. and Contributors. | |
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.1.2. | |
</div> | |
</body> | |
</html> |