CMake Usage Guide: Command-Line Options and Syntax
CMake Usage Guide: Command-Line Options and Syntax
CMake is a powerful cross-platform build system used to generate native build systems for various platforms. This guide explains the basic syntax for using CMake from the command line.
CMake Command-Line Syntax
You can invoke CMake using the following syntax:
cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
cmake [options] -S <path-to-source> -B <path-to-build>
Explanation:
<path-to-source>: Path to the directory containing your project's source code.<path-to-existing-build>: Path to an existing build directory generated by CMake.<path-to-build>: Path to the directory where you want to generate the build system.-S: Specifies the source directory.-B: Specifies the build directory.[options]: Optional arguments affecting CMake's behavior.
Generating a Build System
To (re-)generate a build system for your project:
-
Open a terminal or command prompt.
-
Navigate to the directory where you want to create the build system.
-
Run the appropriate CMake command:
- Generate in the current directory:
cmake <path-to-source> - Generate in a specific directory:
cmake -S <path-to-source> -B <path-to-build> - Re-generate an existing build directory:
cmake <path-to-existing-build>
- Generate in the current directory:
Getting Help
For more information about CMake's options and functionalities, run the following command:
cmake --help
This will display a comprehensive list of available options and their descriptions.
原文地址: https://www.cveoy.top/t/topic/jGlQ 著作权归作者所有。请勿转载和采集!