ModDB Wiki
Advertisement

CMake is a cross platform and open source build system that simplifies the build, test and packaging of a project. CMake is greatly simpler than configure and make. CMake automatically creates native project file or make file based on a simple script that lists the parameters for the project. CMake can conform to simple hobby projects to large professional environments.

Setup[]

To setup CMake for use with your project, first download CMake from the official site and install it. Then in your project's directory, write a CMakeLists.txt similar to the sample below. To use CMake you must have a compiler and linker installed already. Any version of Visual Studio, as well as Make on Unix systems and Cygwin or MingW on windows.

After you have done that, run the command cmake . in the command line. A project file will be generated and you will use that to compile your project. For more information visit the official site, or type cmake --help in the command line.

Specific Project Generation[]

If you want to generate a project file other than the default for your operating system, use the -G command line argument then specify which file type you want to generate.

Example: cmake . -G "Unix Makefile"

Sample CMakeLists.txt[]

Here is a sample script that is used to generate the project or make file.

  1. Sample CMakeLists.txt

project (HELLOWORLD)

  1. We are going to build an executable.
  2. We can list any number of sources here

add_executable (HelloWorld helloworld.cpp)

External Links[]

Advertisement