[CMake] multiple cmake files in one directory

Tyler Roscoe tyler at cryptio.net
Tue Sep 22 12:15:40 EDT 2009


On Tue, Sep 22, 2009 at 05:55:49PM +0200, th.tom at gmx.de wrote:
> I have seen a thread about this issue but there was not a real
> solution, so I try to ask that again: Is there a way to define a
> specific CMakeLists.txt-file with a cmake call.

Maybe you should post a link to the thread so we know what you're
talking about?

> I have two projects, which have the same root directory (what is really nasty but I can't change it actually):
> 
> -data
>   - subdir1
>   - subdir2
>   - subdir3
> 
> These two projects need some subdirectories, so the cmake files would look like this:
> 
> CMakeLists-1.txt: (Project 1)
> [..]
> SUBDIRS(
>    subdir1
>    subdir3
> )
> [..]
> 
> and
> 
> CMakeLists-2.txt: (Project 2)
> [..]
> SUBDIRS(
>    subdir2
> )
> [..]
> 
> I want to build project 1 completly independent from project 2.

subdirs() is deprecated. Use add_subdirectory().

You can explicitly tell CMake the name of your list file with something
like cd build && cmake ../MyCMakeLists.myext.

You could let the CMakeLists in the data directory take care of subdir1
and subdir3 and move the CMakeLists for subdir2 into subdir2.

But basically I think your project organization seems broken and I would
try to fix it rather than hack around it.

tyler


More information about the CMake mailing list