[CMake] Avoiding error when using add_subdirectory twice on same path (CMake 2.6.4)

Tyler Roscoe tyler at cryptio.net
Tue Jun 16 18:23:17 EDT 2009


On Tue, Jun 16, 2009 at 06:04:17PM -0400, Bill Hoffman wrote:
> This was never expected to work, and CMake creates "bad" makefiles in 
> versions of CMake prior to this.   Basically, CMake was over-writing the 
> makefiles as many times as the directory was there.  This causes very 
> odd things to happen, and there were many reports of CMake is broken 
> because of this.   It caused incorrect percent done reporting and 
> sometimes failed to build some targets altogether.   If it was working 
> for you, you were getting lucky (or unlucky...).

It does work well for us with CMake 2.6.2. I have never seen a progress
report > 100% or any other problems that I would attribute to this.

If you can only add a particular source subdirectory once, how do you
handle a "diamond dependency":


   myApp
  /    \
 /      \
lib1   lib2
 \      /
  \    /
 commonLib

lib1 and lib2 both need commonLib, so they both do
add_subdirectory(commonLib). I suppose you could rely on myApp to
perform the add_subdirectory(), but what if I want to build just lib1 or
just lib2 and not build myApp?

tyler


More information about the CMake mailing list