[CMake] Addressing an external MS project as target

Bill Hoffman bill.hoffman at kitware.com
Tue Nov 11 16:44:55 EST 2008


Floca Ralf Omar wrote:
> Hello,
> 
> there is the following situation: I use CMake as build control system
> 
(Windows platform, MS Visual Studio) for my own project (A). A depends
on a second project (B). The project-files of B are pre generated and
not covered by my CMake-Scripts. I use "INCLUDE_EXTERNAL_MSPROJECT" to
integrate B into my solution.
> Until this point everything works fine. But is there any way to
address included external projects (like B) as a target in a CMake
script. I would need this to add dependencies between A and B (e.g.
ADD_DEPENDENCIES(A B)), so that B would also be build when I want to
build A.
> 
> In the documentation and the mailing list I have found no information
> 
how to do this. And it seems that INCLUDE_EXTERNAL_MSPROJECT has no
possibilities to introduce a Target identifier (like ADD_CUSTOM_TARGET).
> 
> I am thankful for any clues or tips that could help me to represent
the project dependency in my CMake scripts.
> 
> Kind regards,
> 
> Ralf Floca
> 


I have not tried this, but....


INCLUDE_EXTERNAL_MSPROJECT_projectname should be the name of the target.

So, this might work:
include_external_msproject(B /some/path)
add_dependencies(A B)


Also, in the command itself you can list the targets it depends on:

include_external_msproject(projectname location
                            dep1 dep2 ...)

-Bill


More information about the CMake mailing list