<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <tt>Hi folks,</tt><tt><br>
    </tt><tt><br>
    </tt><tt>I am trying to generate a Visual Studio C# project with
      CMake.<br>
      This is what I have so far:</tt><tt><br>
    </tt>
    <blockquote><code><span class="pln">cmake_minimum_required</span><span
          class="pun">(</span><span class="pln">VERSION </span><span
          class="lit">3.10</span><span class="pun">)</span><span
          class="pln"><br>
          <br>
          project</span><span class="pun">(</span><span class="pln">myProject
          VERSION </span><span class="lit">0.1</span><span class="pun">.</span><span
          class="lit">0</span><span class="pln"> LANGUAGES </span><span
          class="typ">CSharp</span><span class="pun">)</span><span
          class="pln"><br>
          add_library</span><span class="pun">(</span><span class="pln">myLib
          SHARED src</span><span class="pun">/</span><span class="pln">file1</span><span
          class="pun">.</span><span class="pln">cs src</span><span
          class="pun">/</span><span class="pln">file2</span><span
          class="pun">.</span><span class="pln">cs src</span><span
          class="pun">/</span><span class="pln">file3</span><span
          class="pun">.</span><span class="pln">cs</span><span
          class="pun">)</span><span class="pln"><br>
          set_property</span><span class="pun">(</span><span class="pln">TARGET
          myLib PROPERTY<br>
                       VS_DOTNET_TARGET_FRAMEWORK_VERSION </span><span
          class="str">"netstandard1.4"</span><span class="pun">)</span></code><tt><br>
      </tt></blockquote>
    <code><span class="pun"></span></code><code><span class="pun"></span></code><tt>I
      got the framework name from a .csproj file I generated with<br>
      Visual Studio that looks like this:</tt><br>
    <blockquote>
      <pre class="default prettyprint prettyprinted" style=""><code><span class="tag"><Project</span><span class="pln"> </span><span class="atn">Sdk</span><span class="pun">=</span><span class="atv">"Microsoft.NET.Sdk"</span><span class="tag">></span><span class="pln">
  </span><span class="tag"><PropertyGroup></span><span class="pln">
    </span><span class="tag"><TargetFramework></span><span class="pln">netstandard1.4</span><span class="tag"></TargetFramework></span><span class="pln">
  </span><span class="tag"></PropertyGroup></span><span class="pln">
</span><span class="tag"></Project></span></code></pre>
    </blockquote>
    <tt>This is what I need in order to build the library for .NET
      Standard 1.4.<br>
      However, CMake generates this (among all the other stuff):<br>
    </tt>
    <blockquote>
      <pre class="default prettyprint prettyprinted" style=""><code><span class="tag"><TargetFrameworkVersion></span><span class="pln">netstandard1.4</span><span class="tag"></TargetFrameworkVersion>
</span></code></pre>
    </blockquote>
    <pre class="default prettyprint prettyprinted" style=""><code><span class="tag"></span></code>This does not seem to be valid, since Visual Studio complains that
it cannot open the project. I did not find anything in the
CMake documentation to set <code><TargetFramework></code> instead of <code><TargetFrameworkVersion></code>.

I also tried to go along with a "normal" TargetFrameworkVersion, "4.6.1".
If I do this, the generated project will target ".NET Framework 4.6.1" and I
cannot change the target framework to ".NET Standard 1.4" in Visual Studio via
the dropdown, as the option is not available. Visual Studio seems to be unable
to switch a project from .NET Framework to .NET Standard after it has been created.

Is it possible to generate a project targeting .NET Standard with CMake?

Thanks,

Felix
<code><span class="tag"></span></code></pre>
    <code><span class="pun"></span></code>
  </body>
</html>