[CMake] Add multiple directories

BRM bm_witness at yahoo.com
Mon Feb 18 16:22:11 EST 2008


I'm just thinking here, so please tell me if this wouldn't work...but wouldn't it be easier to have a CMake macro that could (a) find the SVN (or TSVN) install, (b) checkout/export from a repository provided at minimal the URL and revision are provided, and optionally prompts for a user/password, to a separate directory, and (c) adds the directory the code is checked-out/exported to to the build? (Perhaps the macro could be in a more generic form to work with multiple RCS's - e.g. CVS, SVN, VSS, ClearQuest, etc.).

A couple examples:

// Put the files in the build directory
SET(CheckoutPath ${<projectname>_BINARY_DIR}/rcs_deps)

// Generic RCS tool
RCS_CHECKOUT(RCS, /path/to/repository, 1384, ${CheckoutPath})
// SVN minimal
RCS_CHECKOUT(SVN, https://url.to.repository, r1384, ${CheckoutPath})
// CVS minimal
RCS_CHECKOUT(CVS, https://url.to.repository, 1384, ${CheckoutPath})
// SVN with user name and password prompt
RCS_CHECKOUT(SVN, https://url.to.repository, r1384, ${CheckoutPath}, RCS_USERNAME_AND_PASSWORD_PROMPT)
// CVS with user name and password prompt
RCS_CHECKOUT(CVS, https://url.to.repository, 1384, ${CheckoutPath}, RCS_USERNAME_AND_PASSWORD_PROMPT)
// SVN with anonymous user
RCS_CHECKOUT(SVN, https://url.to.repository, r1384, ${CheckoutPath}, RCS_USE_ANONYMOUS_USER)

Perhaps even allow for some macros of the RCS tool:

// Retrieve the revision from the svn:external property list at the given path.
RCS_CHECKOUT(SVN, https://url.to.repository, SVN_EXTERNAL_PROP_GET(PATH, DEPENDANCY_REVISION), ${CheckoutPath})

Just a thought...would be very useful to help with cross-repository dependencies.

Ben

----- Original Message ----
From: Alexander Neundorf <a.neundorf-work at gmx.net>
To: cmake at cmake.org
Sent: Monday, February 18, 2008 3:40:18 PM
Subject: Re: [CMake] Add multiple directories

On Monday 18 February 2008, Robert Bielik wrote:
> I'm setting up a project repository with subversion where I'll have
> external libs linked in via svn:externals svn property. Each external lib
> will have a CMakeLists.txt file.
> Ideally, I'd like to have the possibility to include N subdirectories
> without having to alter the CMakeLists.txt file to do it (by just changing
> the svn:externals property).
> Like:
> ADD_SUBDIRECTORY( * )
> Can it be done?

Yes.
You could do file(GLOB */ ) or something like this and then iterate over the 
result and add each directory.

Or you could
if(EXISTS some_dir)
  add_subdirectory(some_dir)
endif(EXISTS some_dir)
if(EXISTS some_other_dir
  add_subdirectory(some_other_dir)
endif(EXISTS some_other_dir)

But actually I wouldn't recommend that.
If you do that, you rely on the dirs at the time cmake runs. There could be 
additional directories which you don't want to have included in your build 
(e.g. a build dir).
And cmake is not automatically rerun if a directory is created.
If you use plain add_subdirectory(), you know that you have to edit the file 
and this will always cause cmake to run again.

Alex
_______________________________________________
CMake mailing list
CMake at cmake.org
http://www.cmake.org/mailman/listinfo/cmake





More information about the CMake mailing list