[CMake] Forcing project to be included in a solution?

Fraser Hutchison fraser.hutchison at gmail.com
Wed Apr 4 21:48:00 EDT 2012


David's original answer does what you require.

Simply include |add_custom_target(Foo ...)| and don't include 
|add_dependencies(Bar Foo)|.

If your project is also called Bar, then Bar.sln will include Foo.vcproj 
and Bar.vcproj, but Foo will not be built when invoking "Build Solution".

Cheers,

Fraser.



On 04/04/2012 21:33, Robert Dailey wrote:
> Sorry I think we are not on the same page.
>
> My custom target is: "Foo"
> My C++ executable target is: "Bar"
>
> I don't want Bar depend on Foo, because I do not want Foo's commands 
> to execute when I build Bar. However, because Bar does not depend on 
> Foo, Foo.vcproj will not be part of Bar.sln. I need a way to make sure 
> that Foo.vcproj opens with Bar.sln without creating that dependency.
>
> I hope this makes a little more sense.
>
> On Wed, Apr 4, 2012 at 2:01 PM, David Cole <david.cole at kitware.com 
> <mailto:david.cole at kitware.com>> wrote:
>
>     Your original message said you didn't want to make it a dependency.
>     So, why then use "add_dependencies" ...?
>
>
>     On Wed, Apr 4, 2012 at 3:00 PM, David Cole <david.cole at kitware.com
>     <mailto:david.cole at kitware.com>> wrote:
>     > Well, add_dependencies means that the custom target will be built
>     > *before* the target that needs it. So it becomes part of "ALL"
>     if the
>     > other target is part of "ALL".
>     >
>     > I thought nothing depended on it, that's why I offered the leave out
>     > "ALL" advice. If something depends on it, then it's going to be
>     > executed before the thing that depends on it...
>     >
>     >
>     >
>     > On Wed, Apr 4, 2012 at 2:35 PM, Robert Dailey
>     <rcdailey.lists at gmail.com <mailto:rcdailey.lists at gmail.com>> wrote:
>     >> I add the custom targets as a dependency
>     with add_dependencies(), and I
>     >> create the targets with add_custom_target(), I don't specify "ALL".
>     >>
>     >> In my test with Visual Studio 2008, building the parent project
>     results in
>     >> these custom targets being built as well. According to your
>     instruction,
>     >> this should not happen, correct?
>     >>
>     >> On Wed, Apr 4, 2012 at 12:10 PM, David Cole
>     <david.cole at kitware.com <mailto:david.cole at kitware.com>> wrote:
>     >>>
>     >>> Sure, just use add_custom_target without the "ALL" argument.
>     If you
>     >>> don't use "ALL", then the project is completely disconnected from
>     >>> ALL_BUILD and everything else, and will only be triggered when you
>     >>> explicitly build that target/project.
>     >>>
>     >>>
>     >>> HTH,
>     >>> David
>     >>>
>     >>>
>     >>> On Wed, Apr 4, 2012 at 12:53 PM, Robert Dailey
>     <rcdailey.lists at gmail.com <mailto:rcdailey.lists at gmail.com>>
>     >>> wrote:
>     >>> > Hi,
>     >>> >
>     >>> > I have a custom target that just runs some commands that
>     have nothing to
>     >>> > do
>     >>> > with building source. For convenience, when generating
>     visual studio
>     >>> > projects, I'd like for that target to be included in the SLN
>     generated
>     >>> > by
>     >>> > project() but I don't want to make it a dependency, since
>     that would
>     >>> > force
>     >>> > it to build when I build any other project in the solution
>     (I think).
>     >>> >
>     >>> > Is there a way to make a vcproj be included in a sln without
>     it building
>     >>> > as
>     >>> > part of the dependency chain?
>     >>> >
>     >>> > Thanks in advance.
>     >>> >
>     >>> > --
>     >>> >
>     >>> > Powered by www.kitware.com <http://www.kitware.com>
>     >>> >
>     >>> > Visit other Kitware open-source projects at
>     >>> > http://www.kitware.com/opensource/opensource.html
>     >>> >
>     >>> > Please keep messages on-topic and check the CMake FAQ at:
>     >>> > http://www.cmake.org/Wiki/CMake_FAQ
>     >>> >
>     >>> > Follow this link to subscribe/unsubscribe:
>     >>> > http://www.cmake.org/mailman/listinfo/cmake
>     >>
>     >>
>
>
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120405/d2863191/attachment-0001.htm>


More information about the CMake mailing list