Struct CMakeTarget

Source
pub struct CMakeTarget {
    pub name: String,
    pub compile_definitions: Vec<String>,
    pub compile_options: Vec<String>,
    pub include_directories: Vec<String>,
    pub link_directories: Vec<String>,
    pub link_libraries: Vec<String>,
    pub link_options: Vec<String>,
    pub location: Option<String>,
}
Expand description

Describes a CMake target found in a CMake package.

The target can be obtained by calling the target() method on a CMakePackage instance.

Use link() method to instruct cargo to link the final binary against the target. There’s currently no way to automatically apply compiler arguments or include directories, since that depends on how the C/C++ code in your project is compiled (e.g. using the cc crate). Optional support for this may be added in the future.

§Example

use cmake_package::find_package;

let package = find_package("OpenSSL").version("1.0").find().unwrap();
let target = package.target("OpenSSL::SSL").unwrap();
println!("Include directories: {:?}", target.include_directories);
println!("Link libraries: {:?}", target.link_libraries);
target.link();

Fields§

§name: String

Name of the CMake target

§compile_definitions: Vec<String>

List of public compile definitions requirements for a library.

Contains preprocessor definitions provided by the target and all its transitive dependencies via their INTERFACE_COMPILE_DEFINITIONS target properties.

§compile_options: Vec<String>

List of options to pass to the compiler.

Contains compiler options provided by the target and all its transitive dependencies via their INTERFACE_COMPILE_OPTIONS target properties.

§include_directories: Vec<String>

List of include directories required to build the target.

Contains include directories provided by the target and all its transitive dependencies via their INTERFACE_INCLUDE_DIRECTORIES target properties.

§link_directories: Vec<String>

List of directories to use for the link step of shared library, module and executable targets.

Contains link directories provided by the target and all its transitive dependencies via their INTERFACE_LINK_DIRECTORIES target properties.

§link_libraries: Vec<String>

List of target’s direct link dependencies, followed by indirect dependencies from the transitive closure of the direct dependencies’ INTERFACE_LINK_LIBRARIES properties

§link_options: Vec<String>

List of options to use for the link step of shared library, module and executable targets as well as the device link step.

Contains link options provided by the target and all its transitive dependencies via their INTERFACE_LINK_OPTIONS target properties.

§location: Option<String>

The location of the target on disk.

Implementations§

Source§

impl CMakeTarget

Instructs cargo to link the final binary against the target.

This method prints the necessary cargo:rustc-link-search=native={}, cargo:rustc-link-arg={}, and cargo:rustc-link-lib=dylib={} directives to the standard output for each of the target’s link_directories, link_options, and link_libraries respectively.

Trait Implementations§

Source§

impl Clone for CMakeTarget

Source§

fn clone(&self) -> CMakeTarget

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CMakeTarget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CMakeTarget

Source§

fn default() -> CMakeTarget

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.