CMake/CPack/CTest/CDash Open Source Tools to Build Test and Deploy C++ Software
132 16 50402
Google Tech Talk
December 7, 2009
CMake/CPack/CTest/CDash Open Source Tools to Build Test and Deploy C++ Software, presented by Bill Hoffman.
CMake has been in development since 1999, and has been used on several large open source projects such as ITK, VTK, ParaView, VXL, Trilinos and CMake itself. Further, KDE, one of the largest OSS projects has adopted CMake, demonstrating that CMake is capable of successfully supporting complex and large software systems. Hence CMake usage is growing rapidly with thousands of daily downloads and inclusion in several Linux distributions.
Unlike many build systems, CMake is designed to be used in conjunction with native build tools enabling developers to use makefiles, Kdevelop projects, Xcode projects, and even MS Visual Studio projects. A simple input language (included in a CMakeLists.txt file) is used to specify which files to build and what types of system introspection tests need to be performed to build the software. A persistent cache file is used to store the system information and avoid the need for user-defined environment variables.
In addition to building software, CMake provides a testing client (CTest) that integrates with the web-based CDash testing server. This server creates dashboards that build a snapshot of the software at a given time. This is critical to cross-platform development since often a change on one platform fails to compile on another one. The testing system provides for nightly builds which use a copy of the software at a specific time each night, experimental tests that can be used to share build results with other developers before committing source code, and continuous build results that test the build each time files are committed to the source control system.
Once the software is built and tested, the CPack tool can be used to package the software. CPack works similar to CMake in that it generates package information for native packaging tools. NSIS, RPM, OSX packages self extracting tar.gz, tar.gz, tar.zip can all be created. CPack information is included as a simple extension to the CMake build files.
This talk will cover the history and features of CMake, CTest, CDash and CPack in the context of a integrated development environment.
Mr. Hoffman is currently Vice President and CTO for Kitware, Inc. He is a founder of Kitware and has been part of the management team since 1999. Bill has 20 years of experience with large C++ systems. He is a lead architect of the CMake cross-platform build system and co-author of the Mastering CMake book. Mr. Hoffman is also involved in the development of the Kitware Quality Software Process and CDash, the software testing server. Mr. Hoffman developed the C++/COM wrapping technology used to create Kitware's ActiViz product line. He has also made major contributions to VTK, ITK and ParaView. As CTO for Kitware, he guides the implementation and development of large-scale computing solutions, and oversees computer infrastructure decisions, including developing Kitware's E-Store technology.
Mr. Hoffman received a B.S in Computer Science from the University of Central Florida, and an M.S in Computer Science from Rensselaer Polytechnic Institute (RPI). He is a graduate of the GE Software Technology Program. Prior to joining Kitware he spent nine years at GE's Global Research Center working in the Computer Vision Group. As an expert in C++ and object-oriented programming, he has planned and taught several graduate level courses at RPI, as well as a course on object-oriented programming at New York University. Mr. Hoffman has been an invited speaker at national and international conferences, such as OSCON, FOSDEM and KDE Developer's Conferences.
By anonymous 2017-09-20
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 into 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 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 think it's a pretty good material to start with. Also, don't forget about CMake mailing lists with very helpful Community.
CMake: Getting Started - comprehensive tutorial from Wiki of the MASH project.
Here is video from webinar recorded in March, 2012 - Introduction to CMake, highly recommended.
The Ultimate Guide to Modern CMake by Rico Huijbers - dedicated to C/C++ projects, explains imported/exported targets and project config files too.
Here is Git repository with CMake tutorial presentation prepared by Eric Noulard available in various printable formats.
Here is a 50 page PDF with Learning CMake by Pau Garcia i Quiles.
Fortran developers, but not only, may find these two articles helpful:
- How LAPACK library enables Microsoft Visual Studio support with CMake and LAPACKE (PDF)
- Fortran for C/C++ developers made easier with CMake
Please, report any broken links in the comments below.