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
impl CMakeTarget
Sourcepub fn link(&self)
pub fn link(&self)
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
impl Clone for CMakeTarget
Source§fn clone(&self) -> CMakeTarget
fn clone(&self) -> CMakeTarget
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CMakeTarget
impl Debug for CMakeTarget
Source§impl Default for CMakeTarget
impl Default for CMakeTarget
Source§fn default() -> CMakeTarget
fn default() -> CMakeTarget
Auto Trait Implementations§
impl Freeze for CMakeTarget
impl RefUnwindSafe for CMakeTarget
impl Send for CMakeTarget
impl Sync for CMakeTarget
impl Unpin for CMakeTarget
impl UnwindSafe for CMakeTarget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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