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

Jon W knowdat at gmail.com
Tue Aug 14 17:22:41 EDT 2007


> > > 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


More information about the CMake mailing list