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
Asked
Active
Viewed 4.4k times
1 Answers
53
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
-
4what does “multi-configuration” mean. Why gcc is not a multi-config. how to judge if it is a multi-config. – Samuel Jun 20 '13 at 09:28
-
7The two I know of are Visual Studio and Xcode. It means that you can change the build type from within the IDE itself. With gcc, you specify the build type when invoking CMake; there's nothing gcc can do to change between build types once CMake has generated its makefile. – Fraser Jun 20 '13 at 10:21