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

Mike Jackson imikejackson at gmail.com
Tue Aug 14 14:55:02 EDT 2007


What I tend to do is create a "Resources" directory at the top level  
of my project. Then inside that directory I put "special" cmake files  
that are needed by individual platforms.

MyProject/
	CMakeLists.txt
         src/foo.cxx
	src/apple/apple.cxx
	Resources/MySpecialAppleCommands.cmake

Then in the top level CMakeLists.txt file add the following:

IF (APPLE)
	INCLUDE (Resources/MySpecialAppleCommands.cmake)
ENDIF(APPLE)

** Just a note on naming directories that hold cmake related files.  
The  temptation is to name it Cmake, or cmakefile, or cmake or  
something like that. DON'T. What will happen is that sometime when  
you let your guard down you will accidentally do "cmake ." from  
within your project directory. That will create all sorts of files,  
most with "cmake" in the name. Having let your guard down and now mad  
that you have to clean this up, you start deleting everything that  
has "cmake" in the name. This is not a good thing as you just deleted  
your own "cmake" directory that held your cmake code. If you have cvs  
or a backup then great. If not then you just lost a bunch of work.  
Yes I did exactly this late one night. The next day I changed my  
"Cmakefiles" directories to "Resources"....

Just my 2 cents...
-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Aug 14, 2007, at 2:39 PM, Jon W wrote:

> 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
>
> Thanks,
> Jon
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list