[CMake] Starting with Cmake

Tyler Roscoe tyler at cryptio.net
Sat Jul 11 21:37:36 EDT 2009


I hope this is a real email address. Posting from a fake one is sketchy.

On Sat, Jul 11, 2009 at 06:04:48PM -0700, ML wrote:
> 1. Is there a doc that describes the 'bare essentials' to a CMake  
> file. What I absolutely need to have in the file.

I think there's one somewhere on the wiki, and there are other examples
that google will find. The _Mastering CMake_ book has a tutorial chapter
that is helpful but not essential.

> 2. Can I call my Cmake file anything? Or do I have to call it  
> CMakeLists.txt?

You can call it something else but I wouldn't recommend it. Actually I'm
not sure if add_subdirectory() will take a file name (but it might).

> 3. Can CMake check out code from SVN?
> 
> 4. Can CMake e-mail build results to a specified e-mail address?

You'll probably want to use CDash for these types of activities. CDash
is sort of an automation/continuous integration wrapper for CMake. It
has its own website, but it integrates nicely with CMake. 

> 5. Say I have something like:
> SET(SRCS file1.c file2.c file3.c)
> Can I write this like:
> SET(SRCS /
> 	file1.c /
> 	file2.c /
> 	file3.c
> )
>
> Like one file name per line like I can do in a gnu Make File?

I'm not sure why you put those / in there (did you mean \ ?) but CMake
is pretty tolerant of whitespace. Just write:

set (srcs
    file1.c
    file2.c
    file3.c
)

> 6. In Make I would define all of my headers too, would I do the same  
> as #5 above? How does the my Add_Executable statement?

This isn't necessary in CMake, although it does make those headers
available for IDE users. You just add them right alongside the source
files: add_executable (${sources} ${headers}).

> 7. How do I tell Cmake to compile to a static library like a .a or .so  
> or .dll?

add_library() takes STATIC and SHARED flags.

hth,
tyler


More information about the CMake mailing list