Дана уторак 14 август 2007, Mike Jackson је написао(ла):
> 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)

That's a good way to separate your platform specific commands, but I don't 
think that's what Jon W asked (might be that I am wrong).

> ** 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"....

That happens sometimes... Especially about 3am or something like that. I 
remember that one time I accidentally made a directory named ~ and afterwards 
did "rm -rf ~". You can imagine how pleased I was at that moment :( Now I 
keep ALL my data on remote SVN servers, DVD backups & so on.

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

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. Else, just use IF(APPLE) to add 
specific sources to the top CMakeLists.txt. Something like this:

set(foo_SOURCES foo/foo.cxx)
set(apple_SOURCES apple/apple.cxx)
set(linux_SOURCES linux/linux.cxx)
set(windows_SOURCES windows/windows.cxx)

if(APPLE)
        set(final_SOURCES ${foo_SOURCES} ${apple_SOURCES})
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
        set(final_SOURCES ${foo_SOURCES} ${linux_SOURCES})
elseif(WIN32)
        set(final_SOURCES ${foo_SOURCES} ${windows_SOURCES})
else(APPLE)
        message(FATAL_ERROR "This OS is unsupported")
endif(APPLE)

add_executable(foo ${final_SOURCES})

I hope this helps you.

-- 
Filip Brcic <[EMAIL PROTECTED]>
WWWeb: http://purl.org/NET/brcha/home/
Jabber: [EMAIL PROTECTED]
ICQ# 40994923
Yahoo! brcha
MSN: [EMAIL PROTECTED]
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to