<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi there<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I build an executable A. I have set up another target A_remote that uses a custom launcher for remote debugging with Visual Studio. What I'm trying to achieve is that before the A_remote target is run, another target
 is run that deploys files to the remote computer. So I add a custom target run_deploy that runs a batch file, and make A_remote depend on it. As run_deploy also copies image files which aren't part of the VS solution, I want it to always run before launching
 A_remote.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">However, when I build the entire solution, I don't want VS to build anything related to remote debugging, which is why I use EXCLUDE_FROM_DEFAULT_BUILD. But when I do that, and build A_remote, VS tells me<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">1>------ Skipped Build: Project: run_deploy, Configuration: Debug x64 ------<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">1>Project not selected to build for this solution configuration
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Here's a sample CMakeLists.txt.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">cmake_minimum_required(VERSION 3.11.0 FATAL_ERROR)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">file(WRITE main.cpp "int main(){return 0;}\n")<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">file(WRITE deploy.bat "echo Deploying!\n")<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">add_executable(A main.cpp)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">add_executable(A_remote main.cpp)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">add_custom_target(run_deploy "${CMAKE_SOURCE_DIR}/deploy.bat")<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">set_target_properties(run_deploy PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">add_dependencies(A_remote run_deploy)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The documentation https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD.html says "Exclude target from Build Solution." This might have been the intention, but the way it is implemented seems to do more
 than that.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Anyways, how can I achieve that run_deploy is always built when I build A_remote, but not when I build the solution or ALL_BUILD? Is that even possible? Is there a workaround?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Andreas<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
Follow this link to read our <a href="https://www.stryker.com/content/stryker/gb/en/legal/global-policy-statement.html/">
Privacy Statement</a>
</body>
</html>