On Fri, Jul 3, 2009 at 2:33 PM, Robert Dailey <span dir="ltr">&lt;<a href="mailto:rcdailey@gmail.com">rcdailey@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><div></div><div class="h5"><div class="gmail_quote">On Fri, Jul 3, 2009 at 3:31 PM, Robert Dailey <span dir="ltr">&lt;<a href="mailto:rcdailey@gmail.com" target="_blank">rcdailey@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<div class="gmail_quote"><div><div></div><div>On Fri, Jul 3, 2009 at 2:54 PM, James Bigler <span dir="ltr">&lt;<a href="mailto:jamesbigler@gmail.com" target="_blank">jamesbigler@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div>On Wed, Jul 1, 2009 at 4:34 PM, Robert Dailey <span dir="ltr">&lt;<a href="mailto:rcdailey@gmail.com" target="_blank">rcdailey@gmail.com</a>&gt;</span> wrote:<br></div></div><div class="gmail_quote">



<div><div></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Hi,<div><br></div><div>If I have the following CMakeLists.txt:</div><div><br></div><div><div><font face="&#39;courier new&#39;, monospace">cmake_minimum_required( VERSION 2.6.4 )</font></div><div><font face="&#39;courier new&#39;, monospace"><br>






</font></div><div><font face="&#39;courier new&#39;, monospace">project( project1 )</font></div><div><font face="&#39;courier new&#39;, monospace">add_executable( project1 source1.cpp )</font></div>
<div><font face="&#39;courier new&#39;, monospace"><br></font></div><div><font face="&#39;courier new&#39;, monospace">project( project2 )</font></div><div><font face="&#39;courier new&#39;, monospace">add_executable( project2 source2.cpp )</font></div>






<div><font face="&#39;courier new&#39;, monospace"><br></font></div><div><font face="&#39;courier new&#39;, monospace">project( project3 )</font></div><div><font face="&#39;courier new&#39;, monospace">add_executable( project3 source3.cpp )</font></div>






<div><br></div><div>If I create visual studio 2008 files with this, I end up getting the following project files:</div><div><br></div><div>project1.vcproj</div><div>project2.vcproj</div><div>project3.vcproj</div><div>project3.sln</div>






<div><br></div><div>The problem here is that I want the SLN file to be named project1.sln (after the first call to project() ). Is there a way I can tell CMake which call to project() in the same directory will generate the &quot;master&quot; project file? Note that if I add a dummy project to the end of the file:</div>






<div><br></div><div><font face="&#39;courier new&#39;, monospace">project( foo )</font></div><div><font face="&#39;courier new&#39;, monospace"><br></font></div>I get:</div>
<div>project1.vcproj</div><div>project2.vcproj</div><div>project3.vcproj</div><div>foo.sln</div><div><br></div><div>So it gives me some limited control over the naming, but it isn&#39;t ideal.</div>
<br></blockquote></div></div><div><br>I typically only do one project in my setups, and I name the project what I want to show up in VS.  I then have lots of add_executables and other targets that show up as &quot;projects&quot; in the VS solution.  I&#39;m not sure what you are trying to gain by having lots of project() calls.</div>



</div></blockquote><div><br></div></div></div><div>What you are doing sounds like:</div><div><br></div><div><div>project( foo )</div><div>add_library( foo STATIC foo1.cpp )</div><div>add_library( foo STATIC foo2.cpp )</div>


<div>add_library( foo STATIC foo3.cpp )</div>
</div><div> </div><div>Is this true? If it is, you can&#39;t do this in v2.6.4. CMake will fail because you are creating multiple libraries with the same name. What exactly is it you are doing?</div></div>
</blockquote></div><br></div></div><div>Interesting, this seems to work:</div><div><br></div><div><div>project( foo )</div><div>add_library( foo1 STATIC foo1.cpp )</div><div>add_library( foo2 STATIC foo2.cpp )</div><div>

add_library( foo3 STATIC foo3.cpp )</div>
<div><br></div><div>This creates a solution called &quot;foo.sln&quot; and 3 projects: &quot;foo1.vcproj&quot;, &quot;foo2.vcproj&quot;, &quot;foo3.vcproj&quot;. Why does this work? I thought for every add_library() there must be 1 call to project(). Since I didn&#39;t call project() for foo1, foo2, or foo3, I don&#39;t know why it&#39;s letting me create those libraries. Can someone explain this behavior?</div>


</div>
</blockquote></div><br>I was under the impression that project() created some kind of scope
that allows you to reset certain variables.  Subdirectories allow you
to create a new scope, but you inherit all the values from the parent. 
I believe project() reset some variables (like for example the list of
targets), so you can have a newish &quot;top&quot; CMakeLists.txt.  I&#39;ve never
done this.  Again, I just setup one project and do a bunch of targets
each with unique names like you described with foo1, foo2, etc..<br>