title: how to specify C# / WPF resource files in cmake
body: <p>I need to specify resource files for <strong>c-sharp / WPF via cmake</strong>, these are image files that need to ship with the application GUI.</p>
  
  <p>In Visual Studio you just: 
  select the image -> Advanced -> Build Action -> select "Resource", this makes it possible to access the images directly in xaml, ex:</p>
  
  <pre><code>&lt;Image Source="png/login.png"/&gt;
  </code></pre>
  
  <p>For reference when done <strong>manually in VS2017</strong> this adds the following lines to the project.csproj:</p>
  
  <pre><code>&lt;ItemGroup&gt;
      &lt;Resource Include="png/login.png"&gt;
        &lt;CopyToOutputDirectory&gt;PreserveNewest&lt;/CopyToOutputDirectory&gt;
      &lt;/Resource&gt;
    &lt;/ItemGroup&gt;
  </code></pre>
  
  <p><strong>So how do I specify resource files in cmake?</strong> </p>
  
  <p>I tried the suggestion here, to no avail:
  <a href="https://gitlab.kitware.com/cmake/cmake/issues/17368" rel="nofollow noreferrer">https://gitlab.kitware.com/cmake/cmake/issues/17368</a></p>
  
  <p>My current CMakeLists.txt looks as follows:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
  
  project(sampleApp VERSION 2.2.0 LANGUAGES CSharp)
  
  include(CSharpUtilities)
  
  add_executable(sampleApp app.config                     
                  App.xaml
                  App.xaml.cs                 
                  MainWindow.xaml
                  MainWindow.xaml.cs
                  Styles.xaml
                  Properties/AssemblyInfo.cs
                  Properties/Resources.Designer.cs
                  Properties/Resources.resx
                  Properties/Settings.Designer.cs
                  Properties/Settings.settings                
                   )
  
  target_link_libraries(sampleApp PRIVATE otherLibrary)
  #
  # Tried this setting (does not work)
  set(RESOURCES "png/login.png")
  set_property(SOURCE ${RESOURCES} PROPERTY VS_TOOL_OVERRIDE "Resource")
  
  csharp_set_designer_cs_properties(
      Properties/AssemblyInfo.cs
      Properties/Resources.Designer.cs
      Properties/Resources.resx
      Properties/Settings.Designer.cs
      Properties/Settings.settings)
  
  csharp_set_xaml_cs_properties(
                  App.xaml
                  App.xaml.cs
                  MainWindow.xaml
                  MainWindow.xaml.cs 
                  Styles.xaml)
  
  
  target_compile_options(sampleApp PRIVATE "/langversion:6")
  target_compile_options(sampleApp PRIVATE "/unsafe")
  
  set_property(SOURCE App.xaml PROPERTY VS_XAML_TYPE "ApplicationDefinition")
  set_property(TARGET sampleApp PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1")
  set_target_properties(sampleApp PROPERTIES WIN32_EXECUTABLE TRUE)
  
  set_property(TARGET sampleApp PROPERTY VS_DOTNET_REFERENCES
  "System"
  "System.Configuration" 
  "System.Configuration.Install" 
  "System.Data" 
  "System.Drawing" 
  "System.Management" 
  "System.Security" 
  "System.Transactions" 
  "System.Web" 
  "System.Xml" 
  "System.Core" 
  "System.Xaml"
  "System.Xml.Linq" 
  "System.Data.DataSetExtensions" 
  "PresentationCore" 
  "PresentationFramework" 
  "Microsoft.CSharp" 
  "Microsoft.Office.Interop.Excel"
  "WindowsBase" 
  )
  
  #
  # Install
  #
  install(TARGETS sampleApp EXPORT sampleAppTargets
    RUNTIME DESTINATION sampleApp/
    ARCHIVE DESTINATION sampleApp/
    LIBRARY DESTINATION sampleApp/
  )
  install(
    FILES
      ${RESOURCES}
    DESTINATION
      sampleApp/
    COMPONENT
      Devel
  )
  </code></pre>