title: CMake Nested Projects and Targets
body: <p>i have a problem on building specific Visual Studio Projects from a CMake source tree. Immagine we have multiple targets in various subdirectories. In one sub-directory we initiate a new project (and solution). The projects in this project targets should be part of ALL_BUILD, but not in the parent ALL_BUILD.</p>
  
  <p>In short:</p>
  
  <pre><code>project(Main)
  
  add_executable(MainApplication ...)
  target_link_libraries(MainApplication PRIVATE Library_A)
  
  add_subdirectory(Library_A)
     add_library(Library_A STATIC ...)
  
  add_subdirectory(Other_Related_Stuff_Using_MainApplication)
     project(OtherRelatedStuff)
     add_custom_target(OtherTarget ... DEPENDS MainApplication)
  </code></pre>
  
  <p>Now with a Visual Studio generator we get two Solution Files. That is right and correct. In both solutions we have these three projects (as OtherReleatedStuff depends on MainApplication beeing built and OtherRelatedStuff is part of the Main-Project).</p>
  
  <p>Now: ALL_BUILD builds all projects.</p>
  
  <p>When i set </p>
  
  <pre><code>set_target_properties(OtherTarget PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
  </code></pre>
  
  <p>...in both solutions OtherTarget is <strong>disabled</strong>. </p>
  
  <p>What i would like to do is:</p>
  
  <p><strong><em>Solution 1:</em></strong>
  In Main.Sln there should be not <strong>OtherTarget</strong>. In <strong>OtherRelatedStuff.sln</strong> there could be MainApplication, but should not build. Maybe there shouldn't be a MainApplication as well.</p>
  
  <p><strong><em>Solution 2:</em></strong>
  In Main.Sln, OtherTarget should never build (excluded from build). In OtherRelatedStuff.sln, OtherTarget should build, but the dependencies don't or should be even visible.</p>
  
  <p>Is there a solution for it?</p>