Conditional Manifest File for Visual Studio
<p>i'm stuck in a problem adding a manifest to a visual studio c++ project. The situation is that we have two different manifest description in Release and Debug. As we are changing the buildsystem to CMake, i need to include them configuration-specifically.</p>

<p>Currently i have for Release:</p>

<pre><code>&lt;?xml version='1.0' encoding='UTF-8' standalone='yes'?&gt;
&lt;assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'&gt;
   &lt;dependency&gt;
      &lt;dependentAssembly&gt;
         &lt;assemblyIdentity type='win32' name='DeliveredComponent' version='1.0.0.0' processorArchitecture='amd64' /&gt;
     &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
&lt;/assembly&gt;
</code></pre>

<p>And for Debug:</p>

<pre><code>&lt;?xml version='1.0' encoding='UTF-8' standalone='yes'?&gt;
&lt;assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'&gt;
   &lt;dependency&gt;
      &lt;dependentAssembly&gt;
         &lt;assemblyIdentity type='win32' name='DeliveredComponent.Debug' version='1.0.0.0' processorArchitecture='amd64' /&gt;
     &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
&lt;/assembly&gt;
</code></pre>

<p>Just do not ask why the Debug component is postfixed with <strong>.Debug</strong>. I can't change it.</p>

<p>Currently I'm adding the manifest with:</p>

<pre><code>add_custom_command(
    TARGET MyExeFile
    POST_BUILD
    COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\MyExeFile.$(Configuration).x64.manifest\" -outputresource:\"$&lt;TARGET_FILE:${targetname}&gt;\;1\" 
    COMMENT "Adding manifest..."
)
</code></pre>

<p>This is deprecated starting with <strong>CMake 3.4</strong>, additionally this post-build step does alter the output file which implies <strong>relinking the executable</strong> afterwards (Visual Studio dependency check).</p>

<p>That is why I whould like to add the *.manifest to the <strong>add_executable</strong> command now (support since 3.4). But how can I switch the manifest?</p>

<p>Is there any possibility (using generator expressions or similar) to select one of two files to be compiled within the project? (DEBUG or RELEASE only). Or can I switch <strong>internally in the manifest</strong> between two paths? Something like </p>

<pre><code>&lt;dependentAssembly configuration='Debug'&gt;
   ...
&lt;/dependentAssembly&gt;
</code></pre>