CMake
lastmod 2024-11-06created 2014-04-2068 edits
CMake (Cross Platform Make) is an open-source project, created by Kitware and the Insight Consortium, to build an alternative to Make that can be used across multiple platforms. It is also called Meta Make because it does not perform the traditional Make process itself, but only generates Make files suited to the specified operating system (solution files on Microsoft Windows). Its biggest advantage is that, unlike the traditional Make centered on Unix-like OSes, once written it supports not only Unix-like systems but also Microsoft Windows programming tools.
Category
- CMakeLists.txt
- CMake:Variables
- CMake:Modules
- CMake:Generators
- CMake:Policies
- CMake:Example
- CMake:Troubleshooting
Test
Package
Compatibility across different CMake versions
- [Recommended] CMake Version Compatibility Matrix
Libraries
Generators
The following generators are available on this platform:
| Visual Studio 15 [arch] | Generates Visual Studio 15 project files. Optional [arch] can be "Win64" or "ARM". |
| Visual Studio 14 2015 [arch] | Generates Visual Studio 2015 project files. Optional [arch] can be "Win64" or "ARM". |
| Visual Studio 12 2013 [arch] | Generates Visual Studio 2013 project files. Optional [arch] can be "Win64" or "ARM". |
| Visual Studio 11 2012 [arch] | Generates Visual Studio 2012 project files. Optional [arch] can be "Win64" or "ARM". |
| Visual Studio 10 2010 [arch] | Generates Visual Studio 2010 project files. Optional [arch] can be "Win64" or "IA64". |
| Visual Studio 9 2008 [arch] | Generates Visual Studio 2008 project files. Optional [arch] can be "Win64" or "IA64". |
| Visual Studio 8 2005 [arch] | Generates Visual Studio 2005 project files. Optional [arch] can be "Win64". |
| Visual Studio 7 .NET 2003 | Deprecated. Generates Visual Studio .NET 2003 project files. |
| Borland Makefiles | Generates Borland makefiles. |
| NMake Makefiles | Generates NMake makefiles. |
| NMake Makefiles JOM | Generates JOM makefiles. |
| Green Hills MULTI | Generates Green Hills MULTI files (experimental, work-in-progress). |
| MSYS Makefiles | Generates MSYS makefiles. |
| MinGW Makefiles | Generates a make file for use with mingw32-make. |
| Unix Makefiles | Generates standard UNIX makefiles. |
| Ninja | Generates build.ninja files. |
| Watcom WMake | Generates Watcom WMake makefiles. |
| CodeBlocks - MinGW Makefiles | Generates CodeBlocks project files. |
| CodeBlocks - NMake Makefiles | Generates CodeBlocks project files. |
| CodeBlocks - Ninja | Generates CodeBlocks project files. |
| CodeBlocks - Unix Makefiles | Generates CodeBlocks project files. |
| CodeLite - MinGW Makefiles | Generates CodeLite project files. |
| CodeLite - NMake Makefiles | Generates CodeLite project files. |
| CodeLite - Ninja | Generates CodeLite project files. |
| CodeLite - Unix Makefiles | Generates CodeLite project files. |
| Sublime Text 2 - MinGW Makefiles | Generates Sublime Text 2 project files. |
| Sublime Text 2 - NMake Makefiles | Generates Sublime Text 2 project files. |
| Sublime Text 2 - Ninja | Generates Sublime Text 2 project files. |
| Sublime Text 2 - Unix Makefiles | Generates Sublime Text 2 project files. |
| Kate - MinGW Makefiles | Generates Kate project files. |
| Kate - NMake Makefiles | Generates Kate project files. |
| Kate - Ninja | Generates Kate project files. |
| Kate - Unix Makefiles | Generates Kate project files. |
| Eclipse CDT4 - NMake Makefiles | Generates Eclipse CDT 4.0 project files. |
| Eclipse CDT4 - MinGW Makefiles | Generates Eclipse CDT 4.0 project files. |
| Eclipse CDT4 - Ninja | Generates Eclipse CDT 4.0 project files. |
| Eclipse CDT4 - Unix Makefiles | Generates Eclipse CDT 4.0 project files. |
How to install
Official
$ curl -L -O https://github.com/Kitware/CMake/releases/download/v3.18.0/cmake-3.18.0-Linux-x86_64.sh
$ chmod +x cmake-3.18.0-Linux-x86_64.sh
$ sudo ./cmake-3.18.0-Linux-x86_64.sh --skip-license --prefix=/usr/local
Or in one line:
$ curl -s -L "https://github.com/Kitware/CMake/releases/download/v3.18.0/cmake-3.18.0-Linux-x86_64.tar.gz" | tar vxzf - --strip-components=1
Ubuntu cmake 3.x
The cmake in Ubuntu's official repository is not version 3.x. If you want to upgrade the version, add a repository as follows.
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:george-edison55/cmake-3.x
$ sudo apt-get update
$ sudo apt-get install cmake cmake-data
Debug build
Build command
cmake ..
## Debug, Release 빌드 방법
cmake --build . --config Debug
cmake --build . --config Release
## 설치 방법
cmake --build . --target install
How to build from the directory containing the CMakeLists.txt file without changing directories:
cmake -B ./cmake-build-release -DCMAKE_BUILD_TYPE=Release
cmake --build ./cmake-build-release --config Release
Convert
- Converters from other buildsystems to CMake
- Stackoverflow - Tutorial for converting Autotools to CMake
- Converting autoconf, autotools, automake projects to CMake
See also
Favorite site
- CMake website
- Wikipedia (en) CMake description
- Writing CMake scripts 1
- Development/Tutorials/CMake (ko)
- Teaching CMake’s Eclipse Plugin C++11
Turorial & Guide
- CMake Tutorial
- CMake Useful Variables
-
CMake Wiki: FAQ-> CMake Wiki: FAQ - CMake Tutorial #01. Definitions/Concepts
- [Recommended] KLDP: Explanation of how to use CPK 2.3.5
- Integrating external or internal projects in cmake
- Merging static libraries into one in cmake
- Introduction to CMake and how to use it
- [Recommended] CMake Tutorial #2 - Key commands 2
- CMake Useful Variables
- A list of common CMake antipatterns
- Development/Tutorials/CMake (ko)
- [Recommended] Version management using Cmake
- [Recommended] Merging static libraries into one in cmake
- Using gtest with cmake
- [Recommended] An Introduction to Modern CMake · Modern CMake 3
Performance
Article
References
- Build Automation
- C++
- Caffe
- Clangd
- CMake:Example
- CMake:Modules
- CMake:Policies
- CMake:Troubleshooting
- CMake:Variables
- CMakeLists.txt
- Compile commands.json
- Continuous Integration
- ContinuousIntegration:ImplementationGuide
- CPackDeb
- CTest
- CUDA:Example
- Dolphin Emulator
- Dpkg
- Google C++ Testing Framework
- Hierarchical Data Format
- Ios-cmake
- IPhone
- Meson
- Objective-C
- Ogre3d
- Ogre:Android
- OpenCV
- OpenCV:Example:CarCounting
- OpenCV:Troubleshooting
- Tbag
- WebRTC:NativeCode
- YouCompleteMe