[CMake] multiple CMakeLists.txt files in the same directory
Jon W
knowdat at gmail.com
Tue Aug 14 17:58:41 EDT 2007
On 8/14/07, Filip Brcic <brcha at users.sourceforge.net> wrote:
> Дана уторак 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>
That sounds like it would work fine if all of the options are the
same, but may be difficult to separate compiler options,
link_directories, include paths, and custom commands, per project.
I'm guessing that every CMakeLists_project.txt would then need to IF
block every listing that isn't specifically linked to that project's
dll/exe.
-Jon
More information about the CMake
mailing list