pub struct CMakeBuilder { /* private fields */ }
Expand description
Builder for cloning, configuring, building and installing a CMake project.
Implementations§
Source§impl CMakeBuilder
impl CMakeBuilder
Sourcepub fn clone(name: &str, url: &str, tag: &str) -> CMakeBuilder
pub fn clone(name: &str, url: &str, tag: &str) -> CMakeBuilder
Create a new CMakeBuilder
from a git repository.
This function uses the git command therefore it will inherit the git configuration and credentials from your system.
Sourcepub fn from(name: &str, path: &Path) -> CMakeBuilder
pub fn from(name: &str, path: &Path) -> CMakeBuilder
Create a new CMakeBuilder
from an existing cmake project.
Sourcepub fn from_build_directory(name: &str, build_path: &Path) -> CMakeBuilder
pub fn from_build_directory(name: &str, build_path: &Path) -> CMakeBuilder
Create a new CMakeBuilder
from an existing cmake build directory.
Sourcepub fn generator<T: AsRef<OsStr>>(&mut self, generator: T) -> &mut CMakeBuilder
pub fn generator<T: AsRef<OsStr>>(&mut self, generator: T) -> &mut CMakeBuilder
Sets the build-tool generator (-G
) for this compilation.
If unset, this crate will use the CMAKE_GENERATOR
environment variable
if set. Otherwise, it will guess the best generator to use based on the
build target.
Sourcepub fn generator_toolset<T: AsRef<OsStr>>(
&mut self,
toolset_name: T,
) -> &mut CMakeBuilder
pub fn generator_toolset<T: AsRef<OsStr>>( &mut self, toolset_name: T, ) -> &mut CMakeBuilder
Sets the toolset name (-T) if supported by generator. Can be used to compile with CLang/LLV instead of msvc when Visual Studio generator is selected.
If unset, will use the default toolset of the selected generator.
Sourcepub fn cflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut CMakeBuilder
pub fn cflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut CMakeBuilder
Adds a custom flag to pass down to the C compiler, supplementing those that this library already passes.
Sourcepub fn cxxflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut CMakeBuilder
pub fn cxxflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut CMakeBuilder
Adds a custom flag to pass down to the C++ compiler, supplementing those that this library already passes.
Sourcepub fn asmflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut CMakeBuilder
pub fn asmflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut CMakeBuilder
Adds a custom flag to pass down to the ASM compiler, supplementing those that this library already passes.
Sourcepub fn define<K, V>(&mut self, k: K, v: V) -> &mut CMakeBuilder
pub fn define<K, V>(&mut self, k: K, v: V) -> &mut CMakeBuilder
Adds a new -D
flag to pass to cmake during the generation step.
Sourcepub fn register_dep(&mut self, dep: &str) -> &mut CMakeBuilder
pub fn register_dep(&mut self, dep: &str) -> &mut CMakeBuilder
Registers a dependency for this compilation on the native library built by Cargo previously.
This registration will modify the CMAKE_PREFIX_PATH
environment
variable for the build system generation step.
Sourcepub fn target(&mut self, target: &str) -> &mut CMakeBuilder
pub fn target(&mut self, target: &str) -> &mut CMakeBuilder
Sets the target triple for this compilation.
This is automatically scraped from $TARGET
which is set for Cargo
build scripts so it’s not necessary to call this from a build script.
Sourcepub fn host(&mut self, host: &str) -> &mut CMakeBuilder
pub fn host(&mut self, host: &str) -> &mut CMakeBuilder
Sets the host triple for this compilation.
This is automatically scraped from $HOST
which is set for Cargo
build scripts so it’s not necessary to call this from a build script.
Sourcepub fn profile(&mut self, profile: &str) -> &mut CMakeBuilder
pub fn profile(&mut self, profile: &str) -> &mut CMakeBuilder
Sets the CMAKE_BUILD_TYPE=build_type
variable.
By default, this value is automatically inferred from Rust’s compilation profile as follows:
- if
opt-level=0
thenCMAKE_BUILD_TYPE=Debug
, - if
opt-level={1,2,3}
and:debug=false
thenCMAKE_BUILD_TYPE=Release
- otherwise
CMAKE_BUILD_TYPE=RelWithDebInfo
- if
opt-level={s,z}
thenCMAKE_BUILD_TYPE=MinSizeRel
Sourcepub fn static_crt(&mut self, static_crt: bool) -> &mut CMakeBuilder
pub fn static_crt(&mut self, static_crt: bool) -> &mut CMakeBuilder
Configures whether the /MT flag or the /MD flag will be passed to msvc build tools.
This option defaults to false
, and affect only msvc targets.
Sourcepub fn configure_arg<A: AsRef<OsStr>>(&mut self, arg: A) -> &mut CMakeBuilder
pub fn configure_arg<A: AsRef<OsStr>>(&mut self, arg: A) -> &mut CMakeBuilder
Add an argument to the cmake
configure step
Sourcepub fn build_arg<A: AsRef<OsStr>>(&mut self, arg: A) -> &mut CMakeBuilder
pub fn build_arg<A: AsRef<OsStr>>(&mut self, arg: A) -> &mut CMakeBuilder
Add an argument to the final cmake
build step
Sourcepub fn env<K, V>(&mut self, key: K, value: V) -> &mut CMakeBuilder
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut CMakeBuilder
Configure an environment variable for the cmake
processes spawned by
this crate in the build
step.
Sourcepub fn always_configure(&mut self, always_configure: bool) -> &mut CMakeBuilder
pub fn always_configure(&mut self, always_configure: bool) -> &mut CMakeBuilder
Forces CMake to always run before building the custom target.
In some cases, when you have a big project, you can disable
subsequents runs of cmake to make cargo build
faster.
Sourcepub fn very_verbose(&mut self, value: bool) -> &mut CMakeBuilder
pub fn very_verbose(&mut self, value: bool) -> &mut CMakeBuilder
Sets very verbose output.
Sourcepub fn build_target(&mut self, target: &str) -> &mut CMakeBuilder
pub fn build_target(&mut self, target: &str) -> &mut CMakeBuilder
Specify the build target for the final cmake
build step, this will
default to all.
Sourcepub fn build(&mut self) -> CMakeBuilder
pub fn build(&mut self) -> CMakeBuilder
Run this configuration, compiling the library with all the configured options.
This will run both the build system generator command and the command to build the library.