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

Tyler Roscoe tyler at cryptio.net
Wed Jun 17 11:34:24 EDT 2009


On Tue, Jun 16, 2009 at 05:54:01PM -0600, Clinton Stimpson wrote:
> your existing CMake files by relying on CMAKE_HOME_DIRECTORY or 
> something like that.
> 
> So for lib1/lib2
> if(NOT CMAKE_HOME_DIRECTORY MATCHES "${CMAKE_CURRENT_SOURCE_DIR}")
>  add_subdirectory(../commonlib commonlib)
> endif(NOT CMAKE_HOME_DIRECTORY MATCHES "${CMAKE_CURRENT_SOURCE_DIR}")

Interesting hack. I think if(NOT ...) is backwards, though; if
CMAKE_HOME_DIRECTORY *is* the same as CMAKE_CURRENT_SOURCE_DIR, then we
are running CMake directly in this buildable and therefore must
add_subdirectory() ourselves. 

Thanks for the idea, Clint.

tyler


More information about the CMake mailing list