Fact-checked by Grok 2 weeks ago

CMake

CMake is an open-source, cross-platform build system generator that enables developers to manage the building, testing, and packaging of software projects in a platform- and compiler-independent manner. Originally developed in 2000 by Bill Hoffman as part of the Insight Toolkit (ITK) project at the National Library of Medicine, CMake was created to support portable C++ development for medical and registration across Unix, Windows, and platforms. It generates native build files for various tools, including Makefiles, , and IDE project files for and , simplifying the configuration of complex build environments. Over the years, CMake has evolved significantly, with key milestones including its adoption by the Visualization Toolkit (VTK) and in 2002, funding from the National Alliance for Medical Image Computing (NA-MIC) in 2004, and the KDE project's switch to in 2006, which helped establish it as a standard for large-scale . By 2016, had adopted CMake, and in 2023, it added support for module dependency information, followed by the release of version 4.0 in March 2025, reflecting its ongoing adaptation to modern programming needs. Today, maintained by Kitware—a company co-founded by —CMake is the build system, boasting over 2 million monthly downloads and widespread use in generating libraries, executables, and wrappers for C, C++, and other languages across diverse ecosystems. Its extensible design allows for multiple builds from a single source tree, handling static and dynamic libraries, complex dependencies, and even graphical configuration via a generated cache file.

Origins

History

CMake was initially developed in 2000 by Kitware Inc. for the Insight Software Consortium, sponsored by the U.S. National Library of Medicine, to address the challenges of building complex Makefiles for the Insight Toolkit (ITK), a medical imaging software project requiring cross-platform portability. The tool emerged from the success of the Visualization Toolkit (VTK), aiming to simplify the build process for C++ applications across multiple operating systems and compilers. Development began on August 31, 2000, with Kitware creating a prototype in a few weeks to meet the consortium's needs. The first stable release, CMake 1.0, arrived in November 2001, marking the tool's public availability under the permissive BSD-3-Clause license, which has remained its licensing model since inception to encourage widespread adoption. Early adoption followed quickly, with integration into and by 2002, supported by funding from national laboratories such as , Sandia, and Lawrence Livermore, which expanded its use in scientific computing projects. In 2004, CMake received funding from the National Alliance for Medical Image Computing (NA-MIC), increasing its use in open-source projects. CMake 2.0, released on June 11, 2004, introduced significant enhancements in cross-platform support, including better handling of Windows and macOS builds, solidifying its role as a versatile alternative to platform-specific tools. A pivotal milestone occurred in 2006 when the project transitioned from autotools to CMake, championed by developer Alexander Neundorf, enabling faster porting of KDE applications to Windows and macOS while adding features like versioning. This integration boosted CMake's visibility in the open-source community and influenced subsequent adoptions, such as LLVM's initial use in 2008 and full switch in 2016. The 3.x series began with CMake 3.0 on June 10, 2014, shifting to a modern target-based that emphasized declarative build descriptions through commands like add_library with INTERFACE types, improving and dependency handling. The evolution continued into the 4.x series, launched with CMake 4.0 on March 29, 2025, which deprecated policies from versions prior to 3.5 to streamline . Subsequent releases built on this foundation; CMake 4.1.0 arrived in August 2025, followed by 4.1.2 as the latest stable version on September 30, 2025. As of November 2025, the 4.2.0 release candidate series, including 4.2.0-rc2 on October 31, 2025, added new generators such as 18 2026 and FASTBuild for distributed caching. These updates reflect CMake's ongoing commitment to modern language features and performance optimizations, maintaining its status as a for development.

Name

The name "CMake" is a portmanteau of "C"—referring to its initial focus on building C and C++ software—and "make", selected to convey a simple, effective build tool in contrast to more complex systems like Imake used in X11 development. It stands for "Cross-platform Make". This naming choice deliberately avoids direct use of "Make" to differentiate from the Unix Make utility, underscoring CMake's function as a meta-build system generator that produces native build files for various platforms and tools rather than executing builds itself. Branding for CMake began with simple text-based representations in its early releases around 2000, evolving to integrate Kitware's corporate visual identity, including a stylized featuring the tool's name in a modern font aligned with the company's and white color scheme.

Features

Generators and IDE support

CMake generators are responsible for producing native build system files from CMake configurations, enabling the creation of Makefiles, build files, project files, and other formats tailored to specific platforms and tools. This abstraction allows developers to write portable build scripts while leveraging optimized native tools for compilation and linking. Major generators include Unix Makefiles for traditional Unix-like systems, which generate standard Makefile syntax for command-line builds; , a high-performance small build system that produces faster incremental builds; generators supporting versions from 9 2008 up to 17 2022, creating solution (.sln) and project files for Microsoft's ; for Apple ecosystems, outputting project files (.xcodeproj) compatible with ; and , which generates project files (.cbp) for the . These generators are selected based on the target environment, with platform-specific defaults such as Unix Makefiles on and macOS, or on Windows. CMake provides native integration with several IDEs through its generators and auxiliary mechanisms. offers direct support via its generators, allowing users to open and build .sln files seamlessly within the . CLion and leverage CMakePresets.json for configuration and the CMake File to access build artifacts and project details, enabling full editing, building, and debugging workflows. For lighter editors, VS Code integrates via the CMake Tools extension, which handles generation and build processes using or other backends, while Vim relies on community plugins like cmake-tools.vim for similar functionality. Introduced in the CMake 4.2 release candidates (as of November 2025), new s enhance support for advanced and emerging workflows: the FASTBuild enables distributed compilation across machines for faster builds in large projects, and the 18 2026 provides experimental compatibility with the unreleased 2026, based on previews. Generators are selected during using the cmake -G command-line option, such as cmake -G [Ninja](/page/Ninja) .. to specify files, or interactively via cmake-gui; the full list of available generators is shown with cmake --help. This selection influences the entire build tree and can be overridden for cross-compilation scenarios.

Build targets

In CMake, build targets form the core organizational units of a build system, representing the logical components such as executables, libraries, or custom tasks that the build process generates or executes. Each target encapsulates the necessary rules for , linking, and other actions, allowing developers to define project outputs declaratively in CMakeLists.txt files. are created using dedicated commands and can have configured to specify sources, dependencies, and build behaviors, promoting and reusability across projects. CMake supports several primary target types. Executable targets are defined with the add_executable() command, which specifies a target name and one or more source files to compile and link into a runnable binary; for example, add_executable(hello hello.cpp) creates an executable named "hello" from the given C++ source. Library targets are created via add_library(), supporting variants such as static libraries (default or specified with STATIC), shared libraries (SHARED), loadable modules (MODULE), object libraries (OBJECT) for intermediate compilation without archiving, and framework bundles on Apple platforms (FRAMEWORK). For instance, add_library(mylib STATIC source1.cpp source2.cpp) produces a static archive. Custom targets, added with add_custom_target(), represent non-binary outputs or tasks like generating documentation or running scripts, without producing compilable artifacts; an example is add_custom_target(gen_docs COMMAND doxygen) to invoke an external tool. Target properties control various aspects of a target's build and usage, set using commands like set_target_properties() since CMake 2.8, which allows assigning values to properties such as SOURCES for listing input files, INCLUDE_DIRECTORIES for header paths, and COMPILE_DEFINITIONS for preprocessor macros. Starting with CMake 2.8.12, finer-grained control became available through dedicated target_* commands, such as target_sources(target PRIVATE file.cpp) to add sources scoped to the target. These properties enable customization of build artifacts, like setting OUTPUT_NAME to rename the generated file or POSITION_INDEPENDENT_CODE for PIC compilation in libraries. The modern target-based API, emphasized since CMake 3.0, shifts away from global variables toward target-centric commands for better encapsulation and portability. Key introductions include target_include_directories() and target_compile_definitions() in CMake 3.0, allowing per-target configuration of includes and defines without affecting the entire project. Linking is handled via target_link_libraries(), which connects targets and propagates properties; for example, target_link_libraries(myexe mylib) links the executable to the library. This command supports scoping keywords—[PRIVATE](/page/Private) for internal use only, [PUBLIC](/page/Public) for both the target and its consumers, and [INTERFACE](/page/Interface) for consumers alone—introduced in CMake 2.8.12 and refined in 3.0 to enable transitive usage requirements, such as automatically passing include directories to dependent targets. This approach fosters hierarchical project designs where targets expose interfaces without exposing implementation details.

Hierarchical configuration

CMake's hierarchical configuration enables the organization of large s into modular components by processing multiple CMakeLists.txt files across directories. The add_subdirectory() command is central to this mechanism, as it instructs CMake to load and execute the CMakeLists.txt file from a specified subdirectory, thereby incorporating its contents into the overall build process. This allows developers to structure s as trees of subprojects, where each subdirectory can define its own targets, dependencies, and settings while maintaining a unified build. For instance, in a with a root directory containing the main CMakeLists.txt and subfolders for libraries or executables, invoking add_subdirectory(src/lib) from the root would process the corresponding file in the src/lib directory, enabling a scalable and maintainable layout. In a typical hierarchical setup, the root CMakeLists.txt file establishes global policies, such as the minimum required CMake via cmake_minimum_required(), the name with project(), and top-level options like enabling languages or setting build types. These settings propagate to subdirectories unless overridden. In contrast, leaf-level CMakeLists.txt files—those in the deepest subdirectories—focus on defining local targets, such as libraries or executables using add_library() or add_executable(), and specifying their immediate dependencies without altering broader configurations. This division promotes , where the root handles overarching setup and leaves manage specific build artifacts, facilitating collaboration in multi-developer environments. Variable scoping in CMake hierarchies is managed through directory and scopes, ensuring isolation while allowing controlled propagation. Each invocation of add_subdirectory() or the function() command creates a new , where variables set with set(VAR VALUE) remain local by default and do not affect parent scopes. To propagate values upward, the PARENT_SCOPE option can be used, as in set(MY_VAR value PARENT_SCOPE), which sets the variable in the immediately enclosing , such as the parent directory. The function() command, in particular, enforces strict scoping to prevent unintended side effects, differing from macros which share the caller's . This design supports clean hierarchies by minimizing global pollution. Best practices for hierarchical CMake projects emphasize avoiding global variables in favor of target-based approaches to enhance modularity and reduce coupling. Instead of relying on directory-wide variables like INCLUDE_DIRECTORIES(), developers should use target-specific commands such as target_include_directories(target PRIVATE path) to attach properties directly to targets, with visibility keywords (PRIVATE, PUBLIC, INTERFACE) controlling propagation to dependents. This target-centric method ensures that subdirectory changes do not inadvertently affect unrelated parts of the project, improving scalability and debuggability in complex builds. For propagation needs, explicit use of PARENT_SCOPE or target properties is recommended over cache variables, aligning with modern CMake principles.

Separate build tree

CMake supports out-of-source builds, which involve running the CMake configuration process from a directory separate from the source code tree, thereby generating all build artifacts in the designated build directory while leaving the source directory pristine. This approach has been a core capability since CMake's early versions and is strongly recommended to avoid mixing generated files with source code. Traditionally, users create a new build directory adjacent to the source directory, navigate into it, and invoke CMake with a path to the source directory, such as mkdir build && cd build && cmake ... Since CMake 3.13, explicit specification of and build directories has been facilitated by the -S and -B command-line options, allowing from any location without changing directories, for example: cmake -S <path-to-[source](/page/source)> -B <path-to-build>. The CMAKE_BINARY_DIR is automatically set to the full path of the top-level build tree during configuration, providing a reliable reference for build system scripts and CMakeLists.txt files to locate generated files relative to the build directory rather than the . This remains distinct from CMAKE_SOURCE_DIR, which points to the tree, enabling clear separation in out-of-source setups. Out-of-source builds enable the creation of multiple parallel build trees from the same source, such as separate directories for Debug and Release configurations, without duplicating the source code or risking conflicts. This supports efficient management of variant builds, as each tree can be configured independently with different options while sharing the underlying source. Key advantages include preventing source pollution by build outputs like object files and executables, simplifying cleanup through deletion of the entire build directory, and improving integration with systems by excluding generated files from the repository. These benefits promote cleaner workflows, especially in large or multi-platform projects.

Dependency management

CMake manages dependencies between build targets through a combination of explicit commands and automated mechanisms, ensuring correct build order, linking, and propagation of compile-time requirements. Internal dependencies within a project are primarily handled via the target_link_libraries() command, which establishes both link-time and compile-time relationships between targets. For external dependencies, CMake provides tools like find_package() to locate pre-installed libraries and FetchContent to fetch and integrate source-based dependencies. Transitive dependencies are propagated using libraries and usage requirements, allowing libraries and other non-compiled components to influence downstream targets seamlessly. Recent enhancements, such as broader integration with files, further streamline dependency discovery.

Internal Dependencies

The target_link_libraries() command is central to defining internal dependencies in CMake projects. It specifies libraries or targets that a given executable or library depends on, creating link-time edges by adding the necessary linker flags and object files during the build process. For compile-time edges, it propagates usage requirements such as include directories, compile definitions, and compiler flags to dependent targets, ensuring that compilation occurs with the correct settings. The command supports visibility scopes—PRIVATE for internal use only, PUBLIC for both the target and its dependents, and INTERFACE for dependents only—which control how dependencies are inherited. For example, to link an executable myexe to a library target mylib while propagating its include paths:
add_executable(myexe main.cpp)
target_link_libraries(myexe PUBLIC mylib)
This setup ensures myexe links against mylib and any targets linking to myexe also inherit mylib's public usage requirements. CMake also automates header dependency scanning for incremental builds, leveraging compiler-specific tools to detect include relationships without manual specification. Introduced in CMake 3.10 for supported generators like and Makefiles, this feature uses compiler flags (e.g., -MD for /) to generate dependency information at compile time, rebuilding affected sources only when headers change. This reduces build times and errors from missed dependencies, particularly in large projects with complex include graphs.

External Dependencies

For system-installed or third-party libraries, find_package() searches for and configures external dependencies, supporting two modes: Module mode, which uses Find<PackageName>.cmake scripts provided by CMake, and Config mode, which relies on package-provided <PackageName>Config.cmake files for precise location and version handling. Config mode is preferred for modern packages as it allows exact version matching and component selection, such as requiring specific sub-libraries. An example invocation for the framework:
find_package(GTest REQUIRED)
target_link_libraries(my_test_exe GTest::gtest_main)
If the package is not found locally, CMake can fail the configuration with REQUIRED or provide fallbacks. Module mode, while legacy, remains useful for older or non-CMake packages via paths in CMAKE_MODULE_PATH. Introduced in CMake 3.11, the FetchContent module addresses cases where dependencies are not pre-installed by downloading and building them from source during the configure step. It declares content via , SVN, or file URLs and integrates the resulting targets seamlessly. For instance:
include(FetchContent)
FetchContent_Declare(
  googletest
  GIT_REPOSITORY https://github.com/google/googletest.git
  GIT_TAG        703bd9caab50b139428cea1aaff9974ebee5742e
)
FetchContent_MakeAvailable(googletest)
add_executable(my_test test.cpp)
target_link_libraries(my_test gtest)
This approach avoids external installation requirements and supports overrides for sub-dependencies, making it ideal for . Enhancements in later versions, such as CMake 3.24, allow find_package() to redirect to FetchContent for unified handling.

Transitive Propagation

Transitive dependencies in CMake are managed through usage requirements and libraries, ensuring that dependencies of dependencies are correctly resolved without explicit repetition. When a target links to another via target_link_libraries(), PUBLIC and items propagate their properties—such as include directories (target_include_directories()) or compile options—to all consuming , forming a that the build system traverses for ordering and configuration. PRIVATE items remain isolated to the direct target. This mechanism prevents over-linking and supports modular designs. For libraries, which lack compiled sources, libraries provide a lightweight way to encapsulate and propagate requirements. Created with add_library(name [INTERFACE](/page/Interface)), they define like includes and definitions that are inherited by linking . An example for a utility :
add_library(myutils [INTERFACE](/page/Interface))
target_include_directories(myutils [INTERFACE](/page/Interface) ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(myutils [INTERFACE](/page/Interface) some_external_lib)  # If it depends on others
target_link_libraries(myexe [PUBLIC](/page/Public) myutils)
Here, myexe and its dependents automatically receive the include paths and any transitive links from myutils, enabling clean separation of interface concerns. This is particularly valuable for template-heavy or inline code, where no linking artifacts are produced but compile-time visibility is essential.

New Features in CMake 4.0

CMake 4.0 introduces broader integration through the cmake_pkg_config() command, allowing native processing of .pc files to generate CMake variables and imported targets without requiring the pkg-config executable. This enhances dependency discovery for systems, where many libraries provide pkg-config metadata for flags and paths. The command extracts details like CFLAGS and LIBS, supporting version constraints and strict parsing. For example:
cmake_pkg_config(EXTRACT mypackage 1.0 REQUIRED)
target_link_libraries(my_target mypackage)
This generates targets like mypackage::mypackage with propagated properties, bridging traditional pkg-config workflows into CMake's target-based system and improving portability across environments.

Flexible project structure

CMake supports both in-source builds, where the build artifacts are generated within the source directory, and out-of-source builds, where a separate build tree is used to keep the source tree pristine and enable multiple configurations without interference. Out-of-source builds are the recommended approach for larger projects, as they facilitate cleaner management of generated files and easier switching between build types like Debug and Release. For complex dependencies, CMake enables superbuilds through the ExternalProject module, which uses the ExternalProject_Add() command to orchestrate the download, configuration, building, and installation of external projects as part of the main build process. This approach allows a top-level CMake project to manage and integrate third-party libraries or components in external trees, ensuring they are built and linked appropriately without embedding their sources directly. CMake's language-agnostic design permits handling multiple programming languages within the same project via the enable_language() command, which activates support for languages such as C, C++ (CXX), Fortran, Java, CUDA, and others depending on the platform and compiler availability. This flexibility allows developers to mix languages seamlessly, for instance, compiling Fortran routines alongside C++ code in a single build configuration. To accommodate custom workflows, CMake integrates with other build systems like or Bazel using custom commands and targets, such as add_custom_command() or add_custom_target(), which execute external scripts or tools during the build phase. For example, a CMake project can invoke 's build process for specific subcomponents via these mechanisms, enabling hybrid setups where CMake oversees the overall structure while delegating parts to alternative tools. Best practices for scalable projects emphasize a minimal root-level CMakeLists.txt file that sets essential options like cmake_minimum_required() and project(), then delegates implementation details to subdirectory CMakeLists.txt files using add_subdirectory(). This structure promotes modularity, where the root handles global settings and subdirectories manage local targets, reducing complexity in large codebases and improving maintainability.

Compiler feature detection

CMake provides several mechanisms to detect and require specific compiler features, ensuring that build configurations align with the capabilities of the selected compiler. This is particularly important for C++ projects where language standards and extensions vary across compilers like , , and MSVC. The primary tools include functions for testing compiler flags and properties for specifying required features, which automatically adjust compile options such as -std=[c++20](/page/C++20) when support is confirmed. One fundamental way to test compiler support is through the check_cxx_compiler_flag function, which verifies if a given flag is accepted by the C++ without producing diagnostics. This , part of the CheckCXXCompilerFlag , uses an internal try_compile test to attempt compilation with the specified flag and caches the result in a for reuse. For instance, to check for support, the following can be used:
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-std=c++20 HAVE_STD_CXX20)
if(HAVE_STD_CXX20)
  target_compile_options(my_target PRIVATE -std=c++20)
endif()
This approach allows conditional application of flags based on detected support, avoiding errors on older compilers. The function has been available since early CMake versions and supports additional variables like CMAKE_REQUIRED_QUIET (added in 3.1) to suppress output during testing. For more structured feature requirements, the target_compile_features command specifies expected features for a target, such as cxx_std_20 for compliance. Introduced in CMake 3.1, this command checks the feature against the compiler's known capabilities stored in variables like CMAKE_CXX_COMPILE_FEATURES and raises a fatal error if unsupported. If the feature is available, it automatically infers and adds necessary flags, such as -std=gnu++20 for compilers. An example is:
add_library(my_library source.cpp)
target_compile_features(my_library PUBLIC cxx_std_20)
Features can be scoped as PRIVATE, PUBLIC, or INTERFACE to control propagation to dependent targets. This mechanism supports both required and optional features, with conditional compilation handled via generator expressions. CMake maintains a list of all known C++ features in the global property CMAKE_CXX_KNOWN_FEATURES, which includes meta-features like cxx_std_20 (added in 3.12) representing full standard support. This property, introduced in 3.1, catalogs over 100 features ranging from basic types (cxx_auto_type) to advanced constructs, independent of the current compiler. In contrast, CMAKE_CXX_COMPILE_FEATURES lists only those supported by the detected compiler, enabling precise requirements. For example, cxx_std_20 ensures the compiler handles C++20 elements like concepts and coroutines, with support tracked for compilers such as GCC 10+ and Clang 10+. Automatic detection of language standards is facilitated by the CMAKE_CXX_STANDARD variable, which sets a default level (e.g., 20) for all targets in the project unless overridden by target properties. Added in 3.1, this variable influences compile flags globally; for example, setting set(CMAKE_CXX_STANDARD 20) prompts CMake to append -std=[c++20](/page/C++20) (or equivalent) during if the supports it. If the specified standard is unavailable, CMake issues a warning unless CMAKE_CXX_STANDARD_REQUIRED is set to ON, in which case it errors out. This provides a straightforward way to enforce modern standards without manual flag testing in simple cases. In CMake 4.0, enhancements to module feature checks were introduced, building on prior module support from 3.28 to include better integration for standard library modules like std with compilers (version 15+). These improvements allow more reliable detection of module-related flags and dependencies, such as those needed for import std;, expanding usability for modular C++ builds across generators like .

Compiler support

CMake supports a range of programming languages as primary targets for building projects, including C, C++, and Fortran, which form the core of its usage in software development. Secondary languages such as CUDA (introduced in version 3.8), HIP (version 3.21), Objective-C (version 3.16), and Swift (version 3.15) are also supported, enabling CMake to handle specialized workloads like GPU programming and Apple ecosystem development. The tool supports various compilers across these languages, with minimum version requirements varying by compiler and feature set. For C and C++, key supported compilers include GCC starting from version 3.4 for C and 4.4 for C++, Clang from 2.9, Microsoft Visual C++ (MSVC) from 2010 (Visual Studio 2010), Intel C++ Compiler from version 12.1, and NVIDIA's NVCC for CUDA from version 7.5. As of 2025, support extends to the MSVC 2026 preview toolset within Visual Studio previews, ensuring compatibility with emerging Microsoft compiler updates. Additional compilers like Cray (8.1+), Fujitsu HPC (4.0+), and PGI/NVHPC (11.0+) are supported for high-performance computing environments.
CompilerMinimum VersionLanguages SupportedSource
C: 3.4+; C++/: 4.4+C, C++,
2.9+C, C++, Objective-C, ,
MSVC2010+ (VS 2010)C, C++,
12.1+C, C++,
NVCC7.5+
CMake is compatible with major platforms including Windows, , macOS, BSD variants (such as and ), , and , with cross-compilation facilitated through toolchain files that allow building for different architectures and operating systems from a single host. This platform support enables developers to maintain portable build configurations across diverse environments. In CMake 4.0, support for policies from versions prior to 3.5 was removed, which impacts projects relying on deprecated behaviors and may affect compatibility with very old compilers that do not align with modern policy standards. CMake provides mechanisms to detect and verify compiler features, as detailed in the Compiler feature detection section.

Packaging

CMake provides packaging capabilities through CPack, an integrated tool that generates binary installers and source packages from CMake projects. By including the CPack module in a project's CMakeLists.txt file via include(CPack), developers can configure and create packages using the cpack executable, which supports a variety of formats suitable for different platforms and distribution methods. CPack supports multiple generators to produce packages such as DEB for Debian-based distributions, RPM for Hat-based systems, NSIS for Windows installers, and archive formats like and TGZ for cross-platform bundles. These generators leverage the installation rules defined in the project's CMake to assemble the final package, allowing for platform-specific customization without altering the core build logic. The install() command is central to specifying files and targets for , directing executables, libraries, headers, and other artifacts to directories relative to CMAKE_INSTALL_PREFIX. For modular installations, the COMPONENT option groups items into logical sets, such as "runtime" or "development," enabling selective and user choices during . CPack integrates these components via the CPackComponent , which allows defining dependencies between components and generating installers that prompt users for selections. Configuration occurs through CPACK_* variables, such as CPACK_PACKAGE_NAME for the package identifier, CPACK_GENERATOR to select output formats, and CPACK_PACKAGE_VERSION for versioning. These variables can be set in CMakeLists.txt or overridden at , providing flexibility for tailored packages. The supports a streamlined one-step process: after building the project, running cpack (or cmake --build . --target package) installs files to a staging directory and bundles them into the final package. Introduced in CMake 4.0, native support for the cmake_pkg_config command enables processing of files directly within CMake, generating imported targets and variables without requiring an external tool, which enhances of dependencies across ecosystems. Additionally, experimental support for the Common Package Specification (CPS) improves dependency by allowing and of transitive dependencies in a standardized format, facilitating better resolution in multi-package scenarios when enabled via CMAKE_EXPERIMENTAL_FIND_CPS_PACKAGES.

GUI

CMake provides two primary graphical user interfaces for interactive configuration of projects: ccmake, a terminal-based curses interface, and cmake-gui, a cross-platform Qt-based application. These tools allow users to edit CMake cache variables, select build generators, and generate build systems without relying on command-line invocation, facilitating easier setup for complex projects. ccmake serves as a lightweight, text-based GUI utilizing the ncurses library to enable interactive editing of CMake variables and management of the CMake cache file (CMakeCache.txt). Users navigate the interface using keyboard controls, such as arrow keys to select variables, Enter to edit values, and 'c' to configure the project or 'g' to generate build files. It displays variable descriptions and supports toggling the view of advanced cache entries by pressing 't', hiding less commonly used options by default to streamline the configuration process. This tool is particularly suited for environments without graphical desktops, such as remote servers or embedded systems, and integrates seamlessly with terminal workflows for iterative cache adjustments. In contrast, cmake-gui offers a full graphical built with , providing a more visual and user-friendly experience across Windows, macOS, and platforms. It features fields for specifying source and build directories, a dropdown for selecting build generators (e.g., , ), and a table for editing cache variables with inline help text. Users can enable a "Search" box to filter variables by name, toggle "Advanced" view via a checkbox to reveal hidden options, and group variables by prefix for better organization. The interface updates in real-time during configuration, warning of errors, and supports from CMakePresets. files for reproducible setups. Both tools can be launched directly from integrated development environments () that support CMake, such as by invoking them via build menus or scripts to handle initial project configuration before IDE-specific project generation. This integration allows developers to leverage the GUIs for fine-tuning options like flags or paths without leaving their primary . Despite their utility, these GUIs have limitations, including a lack of support for scripting or automation, making them unsuitable for pipelines or ; they are designed primarily for one-time or occasional interactive setup rather than repeated executions. Additionally, changing the build after initial configuration requires clearing the build directory, as the becomes tied to the selected .

Precompiled headers and modules

CMake provides support for precompiled headers (PCH) through the target_precompile_headers() command, introduced in version 3.16, which allows specifying a list of header files to precompile for a target to accelerate subsequent compilations by reusing partially processed versions of those headers. This command supports visibility options such as INTERFACE, PUBLIC, and PRIVATE to control how the precompiled headers are propagated to dependent targets, and it generates a PCH file (e.g., cmake_pch.h or cmake_pch.hxx) that is automatically force-included in source files via compiler flags like -include for GCC or /FI for MSVC. Automatic PCH generation is handled by populating target properties like PRECOMPILE_HEADERS, enabling reuse across sources without manual intervention, though care must be taken to ensure consistent compiler settings to avoid mismatches. Unity builds, also known as jumbo builds, are supported via the UNITY_BUILD target property, added in CMake 3.16, which combines multiple source files into fewer "unity" source files to reduce compilation overhead and speed up the build process by minimizing repeated header processing. Developers enable this by setting set_target_properties(target PROPERTIES UNITY_BUILD ON), with the global CMAKE_UNITY_BUILD variable providing default control; the property uses algorithms like BATCH (default, grouping files automatically) or GROUP (explicit via source properties) to form unity files, limited by UNITY_BUILD_BATCH_SIZE to prevent excessively large files. This feature is available for C, C++, CUDA (since 3.31), and Objective-C languages, but requires compatible compilers and may introduce one-definition-rule issues if not managed carefully. CMake introduced experimental support for C++20 header units in version 3.28 (released in 2023), allowing basic integration of modular headers, though full header unit support remains limited as of the latest releases. Full modules, including named modules, are officially supported starting in 3.28 with the and generators (VS 2022+), using file sets of type CXX_MODULES in target_sources() to specify module interface files like .ixx for MSVC or .cppm for others, with automatic scanning for import dependencies to enforce compilation ordering. In CMake 4.0 (released in 2025), enhanced integration for the standard library module (import std;) was added for GCC 15 and later, enabling seamless use of compiler-provided modules alongside custom ones via properties like CXX_MODULE_STD. For Fortran, CMake natively handles module dependencies through automatic scanning of source files for MODULE and USE statements, generating and tracking .mod files since version 3.10, with the Fortran_MODULE_DIRECTORY target property allowing specification of a dedicated output directory for these files to organize builds involving mixed-language projects. This ensures proper dependency resolution without manual intervention, supporting compilers like gfortran and supporting propagation of module interfaces across targets.

Language

Command syntax

CMake commands are invoked in CMakeLists.txt files using a simple, parenthesized syntax that specifies the command name followed by its arguments. The general form is command(arg1 arg2 ... ), where the command name is case-insensitive and the arguments are enclosed in parentheses, separated by whitespace or newlines. Arguments are treated as strings or lists; unquoted arguments are automatically split into lists using (;) as the , unless the semicolon is escaped with a (\;). To preserve semicolons in paths or multi-word arguments (e.g., those containing spaces), arguments can be quoted with double quotes ("...") or enclosed in bracket argument syntax ([=[...]=]), which supports nested content without escaping. Comments in CMake scripts begin with a hash (#) and extend to the end of the line, allowing inline without affecting execution. For multi-line or bracketed comments that might include special characters, the bracket argument syntax can be used, such as #[=[This is a multi-line comment]=]#. When dealing with file paths that include spaces, proper quotation is essential to prevent unintended list splitting; for instance, set(PATH_TO_SOURCE "/path with spaces/main.cpp") ensures the entire path is treated as a single argument. Control flow structures in CMake enable conditional execution and iteration, forming the basis for dynamic script behavior. Conditional blocks use if(condition) paired with endif(), optionally including elseif() or else() for branching; the condition is evaluated as a . Loops are supported via foreach(item IN LISTS listname ITEMS item1 item2 ...) or while(condition), each terminated by endforeach() or endwhile(), respectively, allowing repetition over lists or until a condition fails. These constructs process commands line-by-line within their blocks, with variables (detailed in the Variables and expressions section) often used to store and manipulate loop variables or conditions. CMake provides mechanisms for defining reusable code through and , which differ in and argument evaluation. A is declared with function(name arg1 arg2 ... ) and ended by endfunction(), creating a new variable where arguments are evaluated lazily upon , similar to procedural calls in other languages. In contrast, a uses macro(name arg1 arg2 ... ) and endmacro(), operating in the caller's and substituting arguments textually before evaluation, which can lead to unintended variable capture but allows more direct text replacement. For example, a simple might be defined as:
function(add_numbers a b result)
    math(EXPR ${result} "${a} + ${b}")
endfunction(add_numbers)
This sets ${result} in the 's local , invoked as add_numbers(1 2 output). Macros, however, expand arguments immediately, making them suitable for simple substitutions but riskier for complex logic due to scope sharing.

Variables and expressions

In CMake, variables are fundamental data structures used to store and manipulate values during the and build process. Normal variables are defined using the set() command with the syntax set(<variable> <value>... [PARENT_SCOPE]), which assigns one or more values to the variable in the current ; multiple values automatically form a semicolon-separated . For example, set(MY_LIST item1 item2 item3) creates a variable that can be iterated or joined later in the CMakeLists.txt file. These variables are scope-specific and do not persist beyond the current directory or unless the PARENT_SCOPE option is used to propagate them upward. Cache variables provide persistence across CMake runs and allow user interaction via the CMake or command line, making them ideal for configurable options like build paths or feature flags. They are set with set(<variable> <value>... CACHE <type> <docstring> [FORCE]), where <type> specifies the data type (e.g., BOOL, [STRING](/page/String), PATH), and the optional FORCE overwrites existing cache entries. For instance, set(BUILD_TESTS ON CACHE BOOL "Enable unit tests") stores a value that users can toggle, ensuring reproducibility in multi-run builds. Unlike normal variables, cache entries are written to the CMakeCache.txt and can be queried or modified externally. Properties in CMake extend variables by associating with specific entities like , directories, or the , enabling fine-grained control over build behaviors. They are accessed and manipulated using commands such as get_target_property(<variable> <target> <property>) for target-specific properties or get_directory_property(<variable> [<directory>] <property>) for directory-wide ones. A common example is the INCLUDE_DIRECTORIES property, which can be retrieved with get_target_property(INCLUDES my_target INTERFACE_INCLUDE_DIRECTORIES) to obtain a list of header search paths for a given target, allowing dynamic adjustments based on project needs. Properties support various categories, including those for sources, tests, and entries, and their values can be used interchangeably with regular variables in expressions. Generator expressions, introduced in CMake 3.0, provide a powerful mechanism for conditional logic evaluated at build time rather than configuration time, using the syntax $<expression> within commands like target_include_directories() or . The $<CONFIG> expression returns the active build configuration (e.g., "Debug" or "Release"), enabling config-specific settings, as in target_compile_definitions(my_target PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>), which defines DEBUG_BUILD only for Debug builds. Similarly, $<TARGET_PROPERTY:tgt,prop> retrieves a value from a target, such as $<TARGET_PROPERTY:my_target,INCLUDE_DIRECTORIES>, allowing runtime queries that adapt to the build environment without re-running CMake. These expressions support nesting and logical operators for complex conditions, like version checks on compilers. Since CMake 3.19, the string() command includes support for string manipulation, facilitating the extraction and processing of structured data like package into variables. Using subcommands like JSON GET, values can be queried from a string, as in:
set(package_json "{\"name\": \"example\", \"version\": \"2.1.0\"}")
string(JSON version GET "${package_json}" version)
This assigns "2.1.0" to the version variable, converting elements to CMake-compatible types (e.g., strings, booleans as ON/OFF, or numbers). Other subcommands, such as JSON LENGTH for array/object sizes or JSON SET for modifications, integrate seamlessly with variables, enabling dynamic handling of external data sources like manifest files in modern package ecosystems.

Internals

Implementation

CMake's core engine is implemented in C++ using an object-oriented design that emphasizes and encapsulation to manage the build configuration process. This modular architecture divides responsibilities into distinct components, including reader modules for input processing, evaluator modules for script execution, and writer modules for output generation, enabling extensible handling of commands and configurations. The engine operates in a two-phase manner: first, the configure phase reads and evaluates input files to build an in-memory representation of the project; second, the generate phase produces the necessary build files or projects based on that representation. The parser interprets CMakeLists.txt files as a scripting language, employing a lex/yacc-based lexical analyzer and parser to tokenize and syntactically analyze the input. During this process, it generates dependency graphs by automatically scanning source files for inclusions and other relationships, particularly for languages like C, C++, and , to determine build order and incremental compilation needs. These graphs are represented internally through objects such as cmMakefile for directory-level targets and cmTarget for individual build artifacts, ensuring efficient traversal and resolution of interdependencies. The system maintains project in a file named CMakeCache.txt, which stores persistent variables and settings generated during the initial configure run. This file allows CMake to avoid re-evaluating unchanged aspects across invocations, but it is regenerated or updated if source changes or explicit reconfiguration occurs, preserving user-specified options while adapting to modifications. By design, the decouples from variables, promoting in cross-platform builds. For enhanced IDE integration, CMake introduced a file-based in version 3.14, documented as cmake-file-api(7), which exposes semantic details of the generated buildsystem through JSON-formatted query and reply files in the .cmake/api directory. Clients, such as , initiate queries for objects like codemodel versions to retrieve information on targets, directories, and configurations without needing a persistent . The codemodel uses major version 2 since the API's introduction in 3.14, with minor version updates over time (e.g., to 2.8 in CMake 4.0) providing more detailed structural insights into the buildsystem for improved project navigation and editing support.

Build process

The CMake build process involves a multi-stage that separates , generation of build files, and actual compilation, enabling cross-platform consistency and efficient incremental builds. This out-of-source approach recommends creating a separate build directory to keep files clean and allow multiple build without duplication. The first stage is , where CMake reads the CMakeLists.txt files in the tree, detects the and features, and populates a of variables for reuse. This step uses the command cmake [<options>] -B <build-dir> [-S <source-dir>], with options like -G <generator> to select the build (e.g., Unix Makefiles or ) and -D <var>=<value> to set entries such as build type or paths. During , CMake performs platform detection, resolves dependencies, and stores results in CMakeCache.txt to avoid redundant work on subsequent runs; changes to files or CMakeLists.txt trigger partial reconfiguration to update only affected parts. Following , the generation stage produces native build files tailored to the chosen , such as Makefiles or project files, based on the processed CMake instructions. This is invoked implicitly during the initial cmake run or explicitly with cmake --build <dir> --preset=<name> for preset-based workflows. The resulting files enable the build tool to handle , linking, and dependency resolution. The final building stage compiles and links the project using the generated files, typically via cmake --build <dir> [--target <tgt>] [-- <build-tool-args>], which unifies invocation across generators without needing the native tool directly (e.g., or ). Options include --parallel or -j <jobs> for concurrent builds to speed up large projects, --target <tgt> to build specific like executables or libraries, and --clean-first for cleaning outputs before rebuilding to ensure a fresh state. Reconfiguration integrates seamlessly if source changes are detected, minimizing full rebuilds through dependency tracking. In CMake 4.1, enhancements to the Makefile and generators introduced support for linker launchers in , , and languages via the CMAKE_<LANG>_LINKER_LAUNCHER variable, allowing custom tools to wrap linking steps for better integration with specialized environments.

Additional tools

CMake provides several companion tools that extend its functionality for testing, packaging, and diagnostic reporting. Among these, CTest serves as the primary test driver, enabling automated and integration within CMake projects. By invoking the enable_testing() and add_test() commands in a CMakeLists.txt file, developers can define tests that CTest executes and reports on, supporting runs with the -j option and verbose output via -V. A key feature for selective test execution is the -R <regex> command-line option, which runs only tests whose names match the specified , available since CMake 2.4. CTest also facilitates continuous integration by integrating with CDash, an open-source dashboard application for aggregating and visualizing build and test results across distributed systems. Projects can submit results to a CDash using CTest's dashboard modes—such as Experimental, Nightly, or Continuous—through a sequence of steps including Start, Update, Configure, Build, Test, and Submit, executed via the ctest -S script mode or directly from the command line. This setup allows teams to monitor build health, track regressions, and generate reports without manual intervention. CPack complements CMake by generating installers and packages from the project's installation rules, invoked separately after the CMake configuration and build phases. The cpack command reads a generated CPackConfig.cmake file—produced when the CPack module is included in the CMakeLists.txt—and creates output in formats specified by the -G option, such as ZIP, DEB, or NSIS installers (e.g., cpack -G ZIP). This tool supports a wide range of generators for different platforms, ensuring portable distribution of built artifacts. For handling runtime libraries, particularly on Windows with MSVC, CMake includes the rare but useful InstallRequiredSystemLibraries module, which detects and installs necessary compiler-provided runtime libraries (such as MSVCRT.dll) to avoid dependency issues in distributed binaries. In recent developments, CMake 4.0 introduced support for the SARIF (Static Analysis Results Interchange Format) standard, enabling export of build diagnostics—including static analysis warnings—in a standardized format via the CMAKE_EXPORT_SARIF variable, improving integration with analysis tools and IDEs as of October 2025.

Adoption

CMake has seen widespread adoption across major open-source projects, particularly in C++ ecosystems. The KDE project, one of the earliest large-scale adopters, transitioned to CMake around 2006 to manage its complex, cross-platform framework development. LLVM and Clang, core components of modern compiler infrastructure, have relied on CMake as their primary build system since version 3.8 (2016), enabling reliable target exports for downstream projects. MySQL uses CMake for source configuration and building across platforms, providing extensive options for customization. Boost, a foundational C++ library collection, integrates with CMake through dedicated support modules, facilitating its use in countless CMake-based builds despite its primary b2 tool. Unreal Engine supports CMake natively for Linux builds and external library integration, streamlining cross-platform game development workflows. In a 2024 survey of modern C++ developers, 83% reported using CMake, reflecting its dominance in top GitHub repositories for the language. In industry applications, CMake powers diverse sectors beyond general . In game development, it enables and external C++ library integration for engines like Unreal, supporting rapid iteration in high-performance environments. For scientific computing, the Insight Toolkit (ITK) and are built exclusively with CMake, ensuring for and data visualization pipelines. In embedded systems, CMake's files facilitate cross-compilation to various architectures, making it a staple for resource-constrained device firmware. CMake's growth trajectory traces from a niche tool in the early 2000s, initially developed for ITK and , to the for C++ builds by the , driven by its cross-platform reliability and extensibility. By 2025, it achieves over 2 million downloads per month, underscoring its entrenched role in professional and open-source workflows. Despite its prevalence, adoption faces hurdles, including a for developers accustomed to simpler scripting, which can complicate initial setup for complex configurations. Migrating from legacy systems like Autotools requires manual reconfiguration without automated tools, often demanding significant effort to replicate conditional logic and platform checks.

Examples

Hello world

To create a basic "Hello, World!" program using CMake, begin with a minimal project structure consisting of a single source file and a CMakeLists.txt configuration file. The CMakeLists.txt file specifies the project's requirements and targets. A minimal version includes the following commands:
cmake
cmake_minimum_required(VERSION 3.10)
project(Hello)
add_executable(hello main.cpp)
The cmake_minimum_required command enforces a minimum CMake version to ensure compatibility with required features. The project command declares the project name, which influences variable scoping and default build settings. The add_executable command defines an executable target named hello built from main.cpp. The source file main.cpp contains a standard C++ "Hello, World!" implementation:
cpp
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
This code includes the iostream header for output and prints the greeting in the main function. To build the project, follow these steps from the project root directory (assuming a system; adjust for Windows as needed):
  1. Create a build directory: mkdir build
  2. Enter the build directory: [cd](/page/.cd) build
  3. Configure the build: cmake ..
  4. Compile the project: cmake --build .
These steps generate build files in the build directory using an out-of-source build approach, which keeps source files clean. The cmake .. command reads CMakeLists.txt from the parent directory and configures the project based on the detected compiler and platform. The cmake --build . command invokes the native build tool (e.g., Make on or MSBuild on Windows) to produce the . Upon successful , an named hello (or hello.exe on Windows) is created in the build directory. Running it with ./hello (or hello.exe on Windows) outputs:
Hello, World!
This demonstrates CMake's ability to automate the compilation of a simple C++ program across platforms without manual makefile editing.

Multi-file project

In CMake, multi-file projects are organized using a hierarchical , where the root CMakeLists.txt file invokes subdirectories containing their own build configurations via the add_subdirectory() command. This approach enables modular development, allowing separate CMakeLists.txt files to define libraries, executables, and dependencies within subfolders, while the top-level file orchestrates the overall build. Consider a project with source code divided into a library and an application. The directory structure might include a src/lib subdirectory for the library sources and a src/app subdirectory for the executable. In the root CMakeLists.txt, the following commands integrate these components:
cmake
cmake_minimum_required(VERSION 3.10)
project(MyProject)

add_subdirectory(src/lib)
add_subdirectory(src/app)
The src/lib/CMakeLists.txt file defines a static library target, such as a simple math utility:
cmake
add_library(math math.cpp)
Here, math.cpp contains the library's implementation, and add_library() creates a named math, typically producing a static like libmath.a during the build. In the src/app/CMakeLists.txt file, an executable is created that depends on the :
cmake
add_executable(calc calc.cpp)
target_link_libraries(calc math)
The add_executable() command builds the calc executable from calc.cpp, while target_link_libraries() specifies that calc links against the math , ensuring the executable can access the library's functions at runtime. To handle header includes, modern CMake recommends using target_include_directories() on the library for public interfaces:
cmake
target_include_directories(math PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
This propagates include paths to dependent targets like calc automatically. For integrating external libraries, such as the Eigen linear algebra , the find_package() command locates and configures the . In the root or relevant CMakeLists.txt, add:
cmake
find_package(Eigen3 REQUIRED NO_MODULE)
target_link_libraries(calc Eigen3::Eigen)
This imports Eigen's headers and links its target, assuming Eigen is installed system-wide or via a ; CMake version 3.5 or later is required for this imported target support. The build process remains consistent with single-file projects: run cmake . (or cmake -S . -B build for out-of-source builds) in the project root to generate build files, followed by make (or the appropriate generator command) to compile. This produces the libmath.a static library in the build directory and the calc executable, which can then be run directly. Target linking ensures dependencies are resolved correctly, with the library archived before the executable is linked.

References

  1. [1]
    CMake 4.2.0-rc2 Documentation
    CMake is a tool to manage building of source code. Originally, CMake was designed as a generator for various dialects of Makefile.CMake Tutorial · Cmake(1) · Cmake-generator... · Cmake-commands(7)
  2. [2]
    History of CMake
    CMake was created in 2000 for ITK, then used by VTK and ParaView, and later adopted by KDE, and now is considered a standard build system.
  3. [3]
    About CMake
    CMake's Rich History ... The original author of CMake, Bill Hoffman, is also a co-founder and the current CTO of Kitware. He created CMake in response to the need ...
  4. [4]
    Celebrating 20 Years of CMake! - Kitware, Inc.
    Sep 14, 2020 · On August 31, we celebrated the 20th anniversary of CMake. We recently had a virtual interview with Bill Hoffman, Kitware CTO and founder, ...Missing: history timeline
  5. [5]
    Licensing for CMake
    CMake is distributed under the OSI-approved BSD 3-clause License. The CMake source tree also contains some third-party components with compatible licenses.
  6. [6]
    Cross Platform Make - CMake
    CMake is a cross-platform build system generator and command-line interface used to configure projects and generate build systems.<|control11|><|separator|>
  7. [7]
    CMake 3.0 Release Notes — CMake 4.2.0-rc1 Documentation
    The CMake documentation has been converted to reStructuredText and now transforms via Sphinx (https://www.sphinx-doc.org) into man and html pages.
  8. [8]
    CMake 4.0 Release Notes
    CMake 4.0 includes new File-Based API, command-line options, and removed compatibility with older CMake versions.
  9. [9]
    Software Releases - Kitware, Inc.
    Software Releases ; CMake 4.2.0-rc2 is ready for testing. October 31, 2025 • By John Parent ; CMake 4.2.0-rc1 is ready for testing. October 16, 2025 • By John ...
  10. [10]
    CMake + FASTBuild: Distributed, Cached, and Fast - Kitware, Inc.
    CMake + FASTBuild: Distributed, Cached, and Fast. November 6, 2025. Eduard Voronkin and Bill Hoffman. CMake is a build system and not a build ...
  11. [11]
    cmake(1) — CMake 4.2.0-rc2 Documentation
    The cmake executable is the command-line interface of the cross-platform buildsystem generator CMake.Cmake_generator_platform · Cmake-generators(7) · Cmake_generator_toolset
  12. [12]
    What does the "c" in cmake stand for? - Stack Overflow
    Jan 15, 2017 · It stands for cross-platform. In their own words, CMake is an open-source, cross-platform family of tools designed to build, test and package software.What is the $ORIGIN token in CMake?CMake: Get root project nameMore results from stackoverflow.com
  13. [13]
    cmake-generators(7)
    A CMake Generator is responsible for writing the input files for a native build system. Exactly one of the CMake Generators must be selected for a build tree.Visual Studio 17 2022 · Ninja · MinGW Makefiles · Unix Makefiles
  14. [14]
    IDE Integration Guide — CMake 4.2.0-rc2 Documentation
    IDEs may want to integrate with CMake to improve the development experience for CMake users. This document lays out the recommended best practices for such ...
  15. [15]
    Get started with CMake Tools on Linux - Visual Studio Code
    Jun 11, 2020 · In this tutorial, you'll use the CMake Tools extension for Visual Studio Code to configure, build, and debug a simple C++ CMake project on Linux.
  16. [16]
    CMake 4.2 Release Notes
    The Visual Studio 18 2026 generator was added. This is experimental and based on "Visual Studio 2026 Insiders" because this version of VS has not been released.
  17. [17]
    cmake-buildsystem(7)
    A CMake-based buildsystem is organized as a set of high-level logical targets. Each target corresponds to an executable or library, or is a custom target ...
  18. [18]
  19. [19]
  20. [20]
    cmake-properties(7) — CMake 4.2.0-rc2 Documentation
    CMake properties are categorized into Global Scope, Directories, Targets, Tests, Source Files, Cache Entries, and Installed Files.Cmake_role · Aliased_target · Target_messages · Cmake_configure_depends
  21. [21]
    CMake Release Notes — CMake 3.0.2 Documentation
    **Summary of New Features in CMake 3.0 (Targets, Target Properties, Modern API):**
  22. [22]
    target_link_libraries — CMake 4.2.0-rc2 Documentation
    No readable text found in the HTML.<|control11|><|separator|>
  23. [23]
    add_subdirectory — CMake 4.2.0-rc2 Documentation
    Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.txt and code files are located.
  24. [24]
    How to structure your project — Modern CMake
    I'm going to tell you how to structure the directories in your project. This is based on convention, but will help you.
  25. [25]
    set — CMake 4.2.0-rc2 Documentation
    If the PARENT_SCOPE option is given the variable will be set in the scope above the current scope. Each new directory or function() command creates a new scope.
  26. [26]
    function — CMake 4.2.0-rc2 Documentation
    A function opens a new scope: see set(var PARENT_SCOPE) for details. See the cmake_policy() command documentation for the behavior of policies inside functions.
  27. [27]
    An Introduction to Modern CMake
    This book tries to solve the problem of the poor examples and best practices that you'll find proliferating the web.Introduction to the basics · Installing CMake · Running CMake · Do’s and Don’ts<|control11|><|separator|>
  28. [28]
    Target-based build systems with CMake
    Objectives. Learn that the basic elements in CMake are not variables, but targets. Learn about properties of targets and how to use them.
  29. [29]
    CMAKE_BINARY_DIR — CMake 4.2.0-rc2 Documentation
    - **Definition**: `CMAKE_BINARY_DIR` is the full path to the top level of the current CMake build tree.
  30. [30]
  31. [31]
    find_package — CMake 4.2.0-rc2 Documentation
    ### Summary of `find_package` Handling External Dependencies for System Libraries
  32. [32]
    FetchContent — CMake 4.2.0-rc2 Documentation
    ### Summary of FetchContent for Downloading and Building Dependencies
  33. [33]
    cmake_pkg_config — CMake 4.0.3 Documentation
    This command generates CMake variables and targets from pkg-config format package files natively, without needing to invoke or even require the presence of a ...
  34. [34]
    ExternalProject — CMake 4.2.0-rc2 Documentation
    The ExternalProject_Add() function creates a custom target to drive download, update/patch, configure, build, install and test steps of an external project.Missing: superbuilds | Show results with:superbuilds
  35. [35]
    enable_language — CMake 4.2.0-rc2 Documentation
    Supported languages are C , CXX (i.e. C++), CSharp (i.e. C#), CUDA , OBJC ... The following restrictions apply to where enable_language() may be called:.
  36. [36]
    CMake module - The Meson Build system
    The CMake module provides helper tools for generating cmake package files and supports CMake subprojects, similar to normal Meson subprojects.
  37. [37]
    CMake Tutorial — CMake 4.2.0-rc2 Documentation
    The CMake tutorial provides a step-by-step guide that covers common build system issues that CMake helps address.Step 1: A Basic Starting Point · Step 2: Adding a Library · Step 3: Adding Usage...
  38. [38]
    cmake-compile-features(7)
    There are three use-cases which arise: Compile Feature Requirements, Optional Compile Features and Conditional Compilation Options.
  39. [39]
    CheckCXXCompilerFlag — CMake 4.2.0-rc2 Documentation
    This module provides a command to check whether the C++ compiler supports a given flag. Load this module in a CMake project with: include(CheckCXXCompilerFlag) ...
  40. [40]
    target_compile_features — CMake 4.2.0-rc2 Documentation
    Added in version 3.1. Add expected compiler features to a target. Specifies compiler features required when compiling a given target. If the feature is not ...Missing: detection | Show results with:detection
  41. [41]
    CMAKE_CXX_KNOWN_FEATURES — CMake 4.2.0-rc2 Documentation
    ### Summary of CMAKE_CXX_KNOWN_FEATURES
  42. [42]
    CMAKE_CXX_COMPILE_FEAT...
    See the cmake-compile-features(7) manual for information on compile features and a list of supported compilers.
  43. [43]
  44. [44]
    CMake 4.0 Release Notes — CMake 4.0.4 Documentation
    ### Summary of Compiler Feature Detection, C++20 Modules, and Related Enhancements in CMake 4.0 Release Notes
  45. [45]
    import CMake; the Experiment is Over! - Kitware, Inc.
    Oct 18, 2023 · CMake 3.28 now officially supports C++ 20 named modules with MSVC, Clang, and GCC, requiring a compatible compiler and CMake build.
  46. [46]
    CMake - GitLab
    Nov 17, 2015 · Building CMake. Supported Platforms. Microsoft Windows; Apple macOS; Linux; FreeBSD; OpenBSD; Solaris; AIX. Other UNIX-like operating systems ...
  47. [47]
    CMake - Upgrade Your Software Build System
    CMake is a powerful and comprehensive solution for managing the software build process. CMake ... History · News & Updates · solutions · Support · Training.
  48. [48]
    cmake_minimum_required — CMake 4.2.0-rc2 Documentation
    Changed in version 4.0: Compatibility with versions of CMake older than 3.5 is removed. Calls to · that do not specify at least 3.5 as their policy version ( ...
  49. [49]
    CPack — CMake 4.2.0-rc2 Documentation
    The CPack module generates the configuration files CPackConfig.cmake and CPackSourceConfig.cmake. They are intended for use in a subsequent run of the cpack ...
  50. [50]
    cpack-generators(7) — CMake 4.2.0-rc2 Documentation
    No readable text found in the HTML.<|control11|><|separator|>
  51. [51]
    cpack(1) — CMake 4.2.0-rc2 Documentation
    The cpack executable is the CMake packaging program. It generates installers and source packages in a variety of formats. For each installer or package format, ...
  52. [52]
    install — CMake 4.2.0-rc2 Documentation
    Installation components can be then used by the cmake --install command's --component option and the CPackComponent module. Global target ...
  53. [53]
    CPackComponent — CMake 4.2.0-rc2 Documentation
    This module allows developers to configure the packaging of such components. Contents is assigned to components by the COMPONENT argument of CMake's install() ...Missing: CPS | Show results with:CPS
  54. [54]
    cmake_pkg_config — CMake 4.2.0-rc2 Documentation
    This command generates CMake variables and targets from pkg-config format package files natively, without needing to invoke or even require the presence of a ...Missing: support | Show results with:support
  55. [55]
    Navigating CMake Dependencies with CPS - Kitware, Inc.
    Mar 31, 2025 · CMake took the first step toward a new world of expressing software package information in a new format, the Common Package Specification (CPS).
  56. [56]
    ccmake(1) — CMake 4.2.0-rc2 Documentation
    The ccmake executable is the CMake curses interface. Project configuration settings may be specified interactively through this GUI.
  57. [57]
    User Interaction Guide — CMake 4.2.0-rc2 Documentation
    The features and user interfaces described in this manual are available for all CMake-based build systems by virtue of providing CMake files.
  58. [58]
    cmake-gui(1) — CMake 4.2.0-rc2 Documentation
    The cmake-gui executable is the CMake GUI. Project configuration settings may be specified interactively. Brief instructions are provided at the bottom of the ...
  59. [59]
    target_precompile_headers — CMake 4.2.0-rc2 Documentation
    Precompiling header files can speed up compilation by creating a partially processed version of some header files, and then using that version during ...
  60. [60]
    PRECOMPILE_HEADERS — CMake 4.2.0-rc1 Documentation
    This property holds a semicolon-separated list of header files to precompile specified so far for its target. Use the target_precompile_headers() command to ...
  61. [61]
    UNITY_BUILD — CMake 4.2.0-rc2 Documentation
    This is done by creating a (set of) unity sources which #include the original sources, then compiling these unity sources instead of the originals.
  62. [62]
    cmake-cxxmodules(7)
    There are a number of known limitations of the current C++ module support in CMake. ... No builtin support for import std; or other compiler-provided modules.Missing: feature checks
  63. [63]
    CXX_MODULE_STD — CMake 4.2.0-rc2 Documentation
    CXX_MODULE_STD is a boolean specifying whether the target may use import std; its C++ sources or not. Note. This setting is meaningful only when experimental ...
  64. [64]
    Fortran_MODULE_DIRECTORY — CMake 4.2.0-rc1 Documentation
    Specify output directory for Fortran modules provided by the target. If the target contains Fortran source files that provide modules and the compiler supports ...
  65. [65]
    cmake-language(7) — CMake 4.2.0-rc2 Documentation
    ### Summary of CMake Language Syntax from Official Documentation
  66. [66]
  67. [67]
  68. [68]
    cmake-generator-expressions(7) — CMake 4.2.0-rc2 Documentation
    Generator expressions are evaluated during build system generation to produce information specific to each build configuration. They have the form $<...>.
  69. [69]
    string — CMake 4.2.0-rc2 Documentation
    ### JSON Format Support in `string()` Command (Introduced in CMake 3.19+)
  70. [70]
    The Architecture of Open Source Applications (Volume 1)CMake
    In 1999 the National Library of Medicine engaged a small company called Kitware to develop a better way to configure, build, and deploy complex software ...
  71. [71]
    cmake-file-api(7) — CMake 4.2.0-rc2 Documentation
    CMake provides a file-based API that clients may use to get semantic information about the buildsystems CMake generates. Clients may use the API by writing ...
  72. [72]
    CMake 4.1 Release Notes
    Makefile Generators and Ninja Generators gained support for adding a linker launcher with Fortran , CUDA , and HIP . See the CMAKE_<LANG>_LINKER_LAUNCHER ...
  73. [73]
    ctest(1) — CMake 4.2.0-rc2 Documentation
    The ctest executable is the CMake test driver program. It runs tests and reports results for projects using enable_testing() and add_test().
  74. [74]
    ctest(1) — CMake 3.0.2 Documentation
    The 'ctest' executable is the CMake test driver program that runs tests and reports results for projects using ENABLE_TESTING and ADD_TEST.
  75. [75]
    CTest — CMake 4.2.0-rc2 Documentation
    CTest configures a project for testing and dashboard submissions to CDash. It scans build output for errors and warnings.
  76. [76]
  77. [77]
    InstallRequiredSystemLibraries — CMake 4.2.0-rc2 Documentation
    This module searches for compiler-provided system runtime libraries and adds installation rules for them. Load this module in a CMake project with: include( ...Missing: CCRT | Show results with:CCRT
  78. [78]
    CMake Support for SARIF Format Enhances Build System ...
    The SARIF format supports aggregating results from several tools and runs within one file, with CMake currently only handling its own diagnostic ...
  79. [79]
    CMAKE_EXPORT_SARIF — CMake 4.2.0-rc2 Documentation
    CMAKE_EXPORT_SARIF enables CMake diagnostics output in SARIF format, generating a log file with diagnostic messages. SARIF is a JSON-based standard for static ...Missing: support | Show results with:support
  80. [80]
    KDE Frameworks - Part 2: Extra CMake Modules for Enhancing Your ...
    Nov 18, 2021 · The KDE Community was among the first large, open-source projects that adopted CMake about 15 years ago. Over this time, a lot of experience ...
  81. [81]
    Building LLVM with CMake — LLVM 22.0.0git documentation
    CMake will detect your development environment, perform a series of tests, and generate the files required for building LLVM. CMake will use default values ...
  82. [82]
    2.8.7 MySQL Source-Configuration Options
    The CMake program provides a great deal of control over how you configure a MySQL source distribution. Typically, you do this using options on the CMake ...Cmake Option Reference · Installation Layout Options · Feature Options
  83. [83]
    CMake support infrastructure Boost submodule - GitHub
    The first thing you need to know is that the official Boost releases can't be built with CMake. Even though the Boost Github repository contains a ...
  84. [84]
    CMake and Unreal - C++ - Epic Developer Community Forums
    Sep 12, 2014 · You can definitively get a CMake-driven unreal project. In 4.5 preview, Unreal Engine Linux build process 'natively' generates a CMake file (and makefile so)
  85. [85]
    TOP 20 C++ MARKETING STATISTICS 2025 | Amra And Elma LLC
    Sep 20, 2025 · C++ Marketing Statistics #10: CMake Used by Over 80% of C++ Developers. The majority of C++ developers (over 80%) use CMake as their build tool.
  86. [86]
    Chapter 2 Configuring and Building ITK - Insight Toolkit
    An ITK build requires only CMake and a C++ compiler. ITK ships with all the third party library dependencies required, and these dependencies are used ...
  87. [87]
    CMake - VTK documentation
    This category includes functions to find and build VTK modules. A module is a set of related functionality. These are then compiled together into libraries.
  88. [88]
    Extending ITK for C++ and Python: Build and Test ITK External ...
    Mar 3, 2023 · A notable challenge in creating an external module is the learning curve required for new contributors. In order to fully leverage the ...
  89. [89]
    How do I convert an Autotools project to a CMake project? [closed]
    Aug 20, 2011 · There is no automated tool that will convert an arbitrary build system from autotools to cmake. I have converted a few moderately large projects manually.
  90. [90]
    Using Eigen in CMake Projects - GitLab
    Eigen provides native CMake support which allows the library to be easily used in CMake projects. Note: CMake 3.5 (or later) is required to enable this ...Missing: documentation | Show results with:documentation