I want to use the cmake --build
command to build my project.
This command has a --config
option. I don't know how many different parameters I can assign to. And I found cmake doesn't check if the parameter of --config
is correct or not
There are two different ways to configure with cmake ; one is to run cmake in a fresh directory passing some options on the command line, and the other is to run ccmake and use its editor to change options. For both, assume you are in a directory called debug and the IMP source is in a directory at ../imp .
CMake is a cross-platform build system generator. Projects specify their build process with platform-independent CMake listfiles included in each directory of a source tree with the name CMakeLists. txt. Users build a project by using CMake to generate a build system for a native tool on their platform.
Provide a boolean option that the user can optionally select. option(<variable> "<help_text>" [value]) If no initial <value> is provided, boolean OFF is the default value. If <variable> is already set as a normal or cache variable, then the command does nothing (see policy CMP0077 ).
Introduction. 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 containing custom commands.
You can call cmake --build
like this:
cmake --build . --target MyExe --config Debug
This would be run from your build root, since the directory is passed as .
, and would build the target MyExe
in Debug
mode.
If your build tool is a multi-configuration one (like devenv on Windows), the --config
argument matters. If you pass an invalid parameter as the config type here, the build tool should give an error.
If the build tool isn't multi-config (like gcc), then the --config
argument is ignored. Instead the build type is set via the CMAKE_BUILD_TYPE
CMake variable; i.e. it's set when running CMake, not when running the build tool.
You can pass further options to the build tool by adding them at the end after a --
, e.g to pass -j4
if using gcc:
cmake --build . --target MyExe -- -j4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With