2016-11-30 21:23:28 +00:00
|
|
|
# cmake
|
|
|
|
|
2021-01-21 17:25:34 +00:00
|
|
|
> Cross-platform build automation system, that generates recipes for native build systems.
|
2020-11-16 18:53:30 +00:00
|
|
|
> More information: <https://cmake.org/cmake/help/latest/manual/cmake.1.html>.
|
2016-11-30 21:23:28 +00:00
|
|
|
|
2021-01-18 17:07:09 +00:00
|
|
|
- Generate a build recipe in the current directory with `CMakeLists.txt` from a project directory:
|
2016-11-30 21:23:28 +00:00
|
|
|
|
2021-01-18 17:07:09 +00:00
|
|
|
`cmake {{path/to/project_directory}}`
|
2016-11-30 21:23:28 +00:00
|
|
|
|
2021-01-22 10:45:01 +00:00
|
|
|
- Generate a build recipe, with build type set to `Release` with CMake variable:
|
2021-01-21 17:25:34 +00:00
|
|
|
|
2021-01-22 10:45:01 +00:00
|
|
|
`cmake {{path/to/project_directory}} -D {{CMAKE_BUILD_TYPE=Release}}`
|
2021-01-21 17:25:34 +00:00
|
|
|
|
2023-04-21 07:08:56 +01:00
|
|
|
- Generate a build recipe using `generator_name` as the underlying build system:
|
|
|
|
|
|
|
|
`cmake -G {{generator_name}} {{path/to/project_directory}}`
|
|
|
|
|
2021-01-23 04:17:56 +00:00
|
|
|
- Use a generated recipe in a given directory to build artifacts:
|
2016-11-30 21:23:28 +00:00
|
|
|
|
2021-01-18 17:07:09 +00:00
|
|
|
`cmake --build {{path/to/build_directory}}`
|
2021-01-18 11:07:14 +00:00
|
|
|
|
2021-01-21 17:25:34 +00:00
|
|
|
- Install the build artifacts into `/usr/local/` and strip debugging symbols:
|
|
|
|
|
|
|
|
`cmake --install {{path/to/build_directory}} --strip`
|
|
|
|
|
|
|
|
- Install the build artifacts using the custom prefix for paths:
|
2021-01-18 11:07:14 +00:00
|
|
|
|
2021-01-22 10:45:01 +00:00
|
|
|
`cmake --install {{path/to/build_directory}} --strip --prefix {{path/to/directory}}`
|
2021-01-18 11:07:14 +00:00
|
|
|
|
|
|
|
- Run a custom build target:
|
|
|
|
|
2021-01-21 17:25:34 +00:00
|
|
|
`cmake --build {{path/to/build_directory}} --target {{target_name}}`
|
2023-04-21 07:08:56 +01:00
|
|
|
|
|
|
|
- Display help, obtain a list of generators:
|
|
|
|
|
|
|
|
`cmake --help`
|