[CMake] multiple CMakeLists.txt files in the same directory

Filip Brcic brcha at users.sourceforge.net
Tue Aug 14 17:33:21 EDT 2007


Дана уторак 14 август 2007, Jon W је написао(ла):
> > > > Is it possible to have multiple CMakeLists.txt files within the same
> > > > directory? (We have projects that span/share multiple directories,
> > > > and currently all of the vcproj files are within a single directory
> > > > for easy editing.)
> > > >
> > > > Or, is the suggested route to create a directory structure such as,
> > > >
> > > > /
> > > > src/foo/foo.cxx
> > > > /apple/apple.cxx
> > > >
> > > > cmake/foo/CMakeLists.txt
> > > > /apple/CMakeLists.txt
> >
> > Every CMakeLists.txt file should have it's target. If you wish to make
> > libraries out of every directory and then link them with main() in the
> > top directory then use separate CMakeLists.txt.
> >
> > Filip Brcic <brcha at users.sourceforge.net>
>
> I'm building foo.dll, apple.dll, some.exe, from which the source is
> scattered throughout the src directory.  There are no foo or apple
> directories, so I can't put a CMakeLists.txt file in those specific
> directories.  What I have been doing is to create a main cmake
> directory (next to src) that then has a directory based upon the
> dll/exe name (foo, apple) with a CMakeLists.txt inside.
>
> src/
> cmake/
>           apple/CMakeLists.txt
>           foo/CMakeLists.txt
>
> One of the developers was hoping that we could bypass the extra
> directory structure and have a general directory that has all of the
> dll/exe cmake files inside.  For example,
>   cmakefiles/
>                   CMakeLists_apple.txt
>                   CMakeLists_foo.txt
>
> But, this doesn't sound as though it will work very well.  Thank you
> for your help.
>
> -Jon

But you can do just that as Mike Jackson suggested. Make your 
cmakefiles/CMakeLists_*.txt files and then include them in some master 
CMakeLists.txt, possibly with IF(something) arround that.

-- 
Filip Brcic <brcha at users.sourceforge.net>
WWWeb: http://purl.org/NET/brcha/home/
Jabber: brcha at kdetalk.net
ICQ# 40994923
Yahoo! brcha
MSN: brcha at users.sourceforge.net


More information about the CMake mailing list