[CMake] add_subdirectory() twice => Policy CMP0013 is not set: Duplicate binary directories are not allowed

Michael Hertling mhertling at online.de
Mon Nov 7 19:56:20 EST 2011


On 11/04/2011 06:39 PM, Paul Hansen wrote:
> Hi
> 
> I have several small projects. Some of them may include another project.
> I have one big project that includes all small projects.
> File structure:
> projects
> - p1.cmake (add_subdirectory(dir_project1))
> - p2.cmake (add_subdirectory(dir_project2))
> - dir_project1
> - dir_project2
> 
> Some of these pX.cmake may be called twice meaning that
> add_subdirectory(dir_projectX) is called twice.
> And the above warning appears.
> 
> Is there a way to handle this. E.g
> - with guards like in C header files (tried something like that but did not
> work)
> - checking if the resulting library exists, if yes: don't add:subdirectory()
> 
> Just wandering if there is a defacto or smart way to handle that a
> subproject may be included several times
> 
> Thanks
> Paul

Recently, there has been an interesting discussion about some
related topics that affects this particular one, too; see [1].

Regards,

Michael

[1] http://www.mail-archive.com/cmake@cmake.org/msg38990.html


More information about the CMake mailing list