Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the option "--build" of cmake

Tags:

cmake

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

like image 779
Samuel Avatar asked Jun 19 '13 05:06

Samuel


People also ask

How do I set CMake build options?

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 .

What is CMake build?

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.

What is option in CMake?

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 ).

What is a build target CMake?

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.


1 Answers

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 
like image 125
Fraser Avatar answered Sep 27 '22 19:09

Fraser