Tool-CMake

发布时间 2023-04-12 22:54:03作者: Theseus‘Ship

Tool-CMake

https://cmake.org/
https://cmake.org/download/
https://cmake.org/documentation/
https://cmake.org/runningcmake/
Book: Mastering CMake 3.1 Edition by Ken Martin (Author), Bill Hoffman (Author)
https://github.com/Kitware/CMake


https://gitlab.kitware.com/cmake/community/-/wikis/home
https://cmake.org/cmake/help/latest/index.html


https://cmake.org/cmake/help/latest/guide/tutorial/index.html

Intro

CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice. The suite of CMake tools were created by Kitware in response to the need for a powerful, cross-platform build environment for open-source projects such as ITK and VTK.
CMake is part of Kitware’s collection of commercially supported open-source platforms for software development.


In the C/C++ ecosystem, the best tool for project configuration is CMake. CMake allows you to specify the build of a project, in files named CMakeLists.txt, with a simple syntax (much simpler than writing Makefiles). From those files, CMake can generate projects for the most popular IDEs and build systems on different OSs. It is a must-have tool. It is the de-facto standard in the industry for the C/C++ multiplatform and even for single OS development.

Building CMake from Scratch

1.UNIX/Mac OSX/MinGW/MSYS/Cygwin
You need to have a C++ compiler (supporting C++11) and a make installed. Run the bootstrap script you find in the source directory of CMake. You can use the --help option to see the supported options. You may use the --prefix=<install_prefix> option to specify a custom installation directory for CMake. Once this has finished successfully, run make and make install.

For example, if you simply want to build and install CMake from source, you can build directly in the source tree:

$ ./bootstrap && make && sudo make install
Or, if you plan to develop CMake or otherwise run the test suite, create a separate build tree:

$ mkdir cmake-build && cd cmake-build
$ ../cmake-source/bootstrap && make

2.Windows
There are two ways for building CMake under Windows:

a.Compile with MSVC from VS 2015 or later. You need to download and install a binary release of CMake. You can get these releases from the CMake Download Page. Then proceed with the instructions below for Building CMake with CMake.

b.Bootstrap with MinGW under MSYS2. Download and install MSYS2. Then install the required build tools:

$ pacman -S --needed git base-devel mingw-w64-x86_64-gcc
and bootstrap as above.

Building CMake with CMake

You can build CMake as any other project with a CMake-based build system: run the installed CMake on the sources of this CMake with your preferred options and generators. Then build it and install it. For instructions how to do this, see documentation on Running CMake.

To build the documentation, install Sphinx and configure CMake with -DSPHINX_HTML=ON and/or -DSPHINX_MAN=ON to enable the "html" or "man" builder. Add -DSPHINX_EXECUTABLE=/path/to/sphinx-build if the tool is not found automatically.

Running CMake

https://cmake.org/runningcmake/

  1. Running CMake for Windows / Microsoft Visual C++ (MSVC)
  2. Running CMake on Unix
  3. Running CMake from the command line
  4. CMake cache

CMake Wiki

https://gitlab.kitware.com/cmake/community/-/wikis/home

CMake Reference Documentation

https://cmake.org/cmake/help/latest/index.html

Command-Line Tools

  • cmake(1)
  • ctest(1)
  • cpack(1)

Interactive Dialogs

  • cmake-gui(1)
  • ccmake(1)

Reference Manuals

  • cmake-buildsystem(7)
  • cmake-commands(7)
  • cmake-compile-features(7)
  • cmake-configure-log(7)
  • cmake-developer(7)
  • cmake-env-variables(7)
  • cmake-file-api(7)
  • cmake-generator-expressions(7)
  • cmake-generators(7)
  • cmake-language(7)
  • cmake-modules(7)
  • cmake-packages(7)
  • cmake-policies(7)
  • cmake-presets(7)
  • cmake-properties(7)
  • cmake-qt(7)
  • cmake-server(7)
  • cmake-toolchains(7)
  • cmake-variables(7)
  • cpack-generators(7)

Guides

  • CMake Tutorial
  • User Interaction Guide
  • Using Dependencies Guide
  • Importing and Exporting Guide
  • IDE Integration Guide