Forrest logo
tool overview
On this page you find all important commands for the CLI tool cmake. If the command you are looking for is missing please ask our AI.

cmake

CMake is a cross-platform, open-source build system and command line tool used to manage the build process of software projects. It serves as a higher-level abstraction layer that generates platform-specific build files (e.g., makefiles or project files for IDEs) based on a single, platform-independent CMake configuration file called CMakeLists.txt.

Key features of CMake include:

  1. Platform Independence: CMake allows developers to write build configuration files that are independent of the target platform. This enables building the same source code on different operating systems like Windows, macOS, and Linux, with minimal changes to the build file.

  2. Hierarchical Organization: CMake enables projects to be organized hierarchically using directories and subdirectories. Each subdirectory can contain its own CMakeLists.txt file, allowing for modular and maintainable build configurations.

  3. Dependency Management: CMake supports managing external dependencies by locating required libraries, frameworks, or packages automatically. It provides various commands and functions to find and link dependencies easily.

  4. Customizability: CMake provides many options and variables that allow fine-grained control over the build process. These include compiler flags, linker options, build configurations (like debug or release), and more.

  5. Integration with IDEs: CMake can generate project files for various popular Integrated Development Environments (IDEs) such as Visual Studio, Xcode, and Eclipse. This allows developers to work in their preferred IDE while using CMake as the underlying build system.

  6. Cross-compilation Support: CMake supports cross-compiling, enabling developers to build software for a different target platform than the one they are currently working on. This is particularly useful in embedded systems development or when targeting specific hardware architectures.

Overall, CMake simplifies the build process by providing a unified interface across different platforms and build systems, enabling developers to focus more on writing code rather than managing complex build configurations.

List of commands for cmake:

  • cmake:help cmake: Display help, obtain a list of generators.
    $ cmake --help
    try on your machine
    explain this command
  • cmake:tldr:310e1 cmake: Generate a build recipe using `generator_name` as the underlying build system.
    $ cmake -G ${generator_name} ${path-to-project_directory}
    try on your machine
    explain this command
  • cmake:tldr:43804 cmake: Run a custom build target.
    $ cmake --build ${path-to-build_directory} --target ${target_name}
    try on your machine
    explain this command
  • cmake:tldr:4f572 cmake: Install the build artifacts using the custom prefix for paths.
    $ cmake --install ${path-to-build_directory} --strip --prefix ${path-to-directory}
    try on your machine
    explain this command
  • cmake:tldr:5a69a cmake: Use a generated recipe in a given directory to build artifacts.
    $ cmake --build ${path-to-build_directory}
    try on your machine
    explain this command
  • cmake:tldr:5f197 cmake: Generate a build recipe in the current directory with `CMakeLists.txt` from a project directory.
    $ cmake ${path-to-project_directory}
    try on your machine
    explain this command
  • cmake:tldr:9d462 cmake: Generate a build recipe, with build type set to `Release` with CMake variable.
    $ cmake ${path-to-project_directory} -D ${CMAKE_BUILD_TYPE=Release}
    try on your machine
    explain this command
  • cmake:tldr:f49fd cmake: Install the build artifacts into `/usr/local/` and strip debugging symbols.
    $ cmake --install ${path-to-build_directory} --strip
    try on your machine
    explain this command
tool overview