CMake
Encyclopedia
CMake is a cross-platform, open-source system for managing the build process of software (see Build automation
Build Automation
Build automation is the act of scripting or automating a wide variety of tasks that software developers do in their day-to-day activities including things like:* compiling computer source code into binary code* packaging binary code* running tests...

) using a compiler-independent method. It is designed to support directory hierarchies and applications that depend on multiple libraries, and for use in conjunction with native build environments such as Make, Apple's Xcode
Xcode
Xcode is a suite of tools, developed by Apple, for developing software for Mac OS X and iOS. Xcode 4.2, the latest major version, is available on the Mac App Store for free for Mac OS X 10.7 , and on the Apple Developer Connection website for free to registered developers Xcode is a suite of tools,...

 and Microsoft Visual Studio
Microsoft Visual Studio
Microsoft Visual Studio is an integrated development environment from Microsoft. It is used to develop console and graphical user interface applications along with Windows Forms applications, web sites, web applications, and web services in both native code together with managed code for all...

. It also has minimal dependencies, requiring only a C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

-compiler on its own build system.

History

CMake was developed beginning in 1999 in response to the need for a cross-platform build environment the Insight Segmentation and Registration Toolkit (ITK)
Insight Segmentation and Registration Toolkit
ITK is a cross-platform, open-source application development framework widely used for the development of image segmentation and image registration programs. Segmentation is the process of identifying and classifying data found in a digitally sampled representation. Typically the sampled...

. The project is funded by the United States National Library of Medicine
United States National Library of Medicine
The United States National Library of Medicine , operated by the United States federal government, is the world's largest medical library. Located in Bethesda, Maryland, the NLM is a division of the National Institutes of Health...

 as part of the Visible Human Project
Visible Human Project
The Visible Human Project is an effort to create a detailed data set of cross-sectional photographs of the human body, in order to facilitate anatomy visualization applications. A male and a female cadaver were cut into thin slices which were then photographed and digitized. The project is run by...

. It was partially inspired by pcmaker, which was made by Ken Martin and other developers to support the Visualization Toolkit (VTK)
VTK
The Visualization Toolkit is an open-source, freely available software system for 3D computer graphics, image processing and visualization. VTK consists of a C++ class library and several interpreted interface layers including Tcl/Tk, Java, and Python. Kitware, whose team created and continues to...

. At Kitware
Kitware
Kitware, Inc. is a technology company headquartered in Clifton Park, New York. The company specializes in the research and development of open-source software in the fields of computer vision, medical imaging, visualization, 3D data publishing and technical software development...

, Bill Hoffman blended components of pcmaker with his own ideas, striving to mimic the Unix configure tool’s functionality. CMake was first implemented in 2000 and further developed in 2001. Continued development and improvements were fueled by the incorporation of CMake into developers’ own systems, including:
  • The VXL
    VXL
    VXL, the Vision-something-Library,' is a collection of open source C++ libraries for Computer Vision. The idea is to replace X with one of many letters, ie. G is a geometry library, N is a numerics library, I is an image processing library, etc. These libraries can be used for general scientific...

     Project
  • The CABLE; features added by Brad King
  • GE Corporate R&D for support of DART


Additional features were created when VTK
VTK
The Visualization Toolkit is an open-source, freely available software system for 3D computer graphics, image processing and visualization. VTK consists of a C++ class library and several interpreted interface layers including Tcl/Tk, Java, and Python. Kitware, whose team created and continues to...

 transitioned to CMake for its build environment and for supporting ParaView
ParaView
ParaView is an open source, freely available program for parallel, interactive, scientific visualization. It has a client–server architecture to facilitate remote visualization of datasets, and generates level of detail models to maintain interactive framerates for large datasets. It is an...

.

Features

CMake can handle in-place and out-of-place builds, enabling several builds from the same source tree, and cross-compilation. The ability to build a directory tree outside the source tree is a key feature, ensuring that if a build directory is removed, the source file remains unaffected.

Another feature of CMake is the ability to generate a cache
Cache
In computer engineering, a cache is a component that transparently stores data so that future requests for that data can be served faster. The data that is stored within a cache might be values that have been computed earlier or duplicates of original values that are stored elsewhere...

 to be used with a graphical editor, which, when CMake is run, can locate executables, files and libraries. This information goes into the cache, which can then be tailored before generating the native build files.

Complicated directory hierarchies and applications that rely on several libraries are well supported by CMake. For instance, CMake is able to accommodate a project that has multiple toolkits, or libraries that each have multiple directories. In addition, CMake can work with projects that require executables to be created before generating code to be compiled for the final application. Its open-source, extensible design allows CMake to be adapted as necessary for specific projects.

CMake can generate makefiles for many platforms and IDEs including Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

, Windows, Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, MSVC, Cygwin
Cygwin
Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment...

, MinGW
MinGW
MinGW , formerly mingw32, is a native software port of the GNU Compiler Collection and GNU Binutils for use in the development of native Microsoft Windows applications; MinGW can function either as a cross compiler targeting Windows or as a native toolchain run on Windows itself...

 and Xcode
Xcode
Xcode is a suite of tools, developed by Apple, for developing software for Mac OS X and iOS. Xcode 4.2, the latest major version, is available on the Mac App Store for free for Mac OS X 10.7 , and on the Apple Developer Connection website for free to registered developers Xcode is a suite of tools,...

.

Build process

The build process with CMake takes place in two stages. First, standard build files are created from configuration files. Then the platform's native build tools are used for the actual building.

Each build project contains a CMakeLists.txt file in every directory that controls the build process. The CMakeLists.txt file has one or more commands in the form COMMAND (args...), with COMMAND representing the name of each command and args the list of arguments, each separated by white space. While there are many built-in rules for compiling the software libraries (static
Static library
In computer science, a static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable...

 and dynamic) and executables, there are also provisions for custom build rules. Some build dependencies can be determined automatically. Advanced users can also create and incorporate additional makefile generators to support their specific compiler and OS needs.

See also

  • List of build automation software
  • GNU build system
    GNU build system
    The GNU build system, also known as the Autotools, is a suite of programming tools designed to assist in making source-code packages portable to many Unix-like systems....

  • premake
    Premake
    In software development, premake is a open source utility for automatically building configuration from source code.- Features :Some of the features of the system are:* It supports C, C++, and C# languages source code.* It has a simple syntax...

  • SCons
    SCons
    SCons is a computer software construction tool that automatically analyzes source code file dependencies and operating system adaptation requirements from a software project description and generates final binary executables for installation on the target operating system platform...

  • Waf
    Waf
    Waf is a Build automation tool - a program that assists in the automatic compilation and installation of other programs or libraries.-General:* Portable to Unix and non-Unix systems* Lightweight...


External links



Learning resources for CMake include:
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK