views:

4783

answers:

4
+14  Q: 

CMake tutorial.

Can anyone provide link(s) to good CMake tutorial except very expensive and hard-to-get official one?

Especially interesting in using CMake for Fortran projects but will be grateful for any good tutorial.

Update.

What I already found is CMake articles in Kitware Public Wiki. Fortran example is absolutely useless. =( Also while waiting for answers I'm playing with SCons. Looks nice. =)

A: 

Hi

I'm puzzled -- you want to learn to use an expensive tool but don't want to pay to use the expensive tutorial for it ? Do you have an illicit copy of CMake ?

Regards

Mark

High Performance Mark
Hmmm... CMake is open-source and distributed under New BSD License. What do you mean by "illicit"?
kemiisto
He doesn't want to buy the book.
JesperE
+20  A: 

First, I recommend a very good introduction lecture to CMake and related tools by Bill Hoffman available on YouTube:

CMake/CPack/CTest/CDash Open Source Tools to Build Test and Deploy C++ Software

Next, take a quick overview and feel CMake scripting, quick and simple examples and also a bit of taste of CMake syntax, so it will help you to read CMake scripts.

Now, you can get immediately to hands on Tutorial which is available in CMake CVS. It is no talk, but code tutorial material which is used in the mastering CMake book. Certainly, you will need to refer to the manual to learn details about various macros.

After you grasp foundations of CMake, you can start digging more advanced techniques as well as read existing CMakeLists.txt files to see how others hack CMake scripts.

For real life examples with proper comments, check Bruno Abinader's two-parts tutorial:

I can also recommend Empirical approach to CMAKE

I also found KDE documentations for CMake scripting very useful. It includes a very good introduction Development/Tutorials/CMake. However, some KDE specific features and custom macros may be a little disturbing.

I have started learning CMake quite recently myself and I believe it's a pretty good material to start with. Also, don't forget about CMake mailing lists with very helpful Community.

UPDATE: Tutorial from "Mastering CMake" now online! - Bill Hoffman has just announced on the mailing list. Here it is CMake Tutorial Now on the Web

mloskot
Thanks a lot for the links.
kemiisto
+5  A: 

Fortran should be pretty much the same as C/C++. Just add the .f or .f90 files instead of .c or .cxx files, also include Fortran in the project call. CMake 2.8 has the best support for Fortran of CMake versions. CMake does have some very good Fortran support. It can analyze the source code and order the build based on the required .mod file generation that will happen during the Fortran build. If you have specific questions about Fortran or a compiler that does not work, the CMake mailing list would be the place to go.

Something like this:

project(testf C CXX Fortran)

add_library(hello STATIC hello.f) add_library(world ${_SHARED} world.f world.def) add_executable(testf testf.f) target_link_libraries(testf hello world)

That is from the Fortran test in CMake: http://public.kitware.com/cgi-bin/viewcvs.cgi/Tests/Fortran/?root=CMake

CMake also has a module to determine C/Fortran linkage:

http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/FortranCInterface.cmake?revision=1.19.2.2&root=CMake&view=markup

Bill Hoffman
+2  A: 

Hi guys, Just to let you know that I've moved my blog to a new host ( http://cabledogs.org/abinader ) and the CMake tutorials were moved as well. I intend to continue the tutorial series handling subjects like internationalization (i18n), documentation (doxygen, qdoc), unit tests integration, debug/release modes, multi-platform support and others.

brunoabinader