Skip to content

Instantly share code, notes, and snippets.

@zopsicle
Created September 21, 2024 12:11
Show Gist options
  • Save zopsicle/224d1b8a2220a06d9de4093f39b4168e to your computer and use it in GitHub Desktop.
Save zopsicle/224d1b8a2220a06d9de4093f39b4168e to your computer and use it in GitHub Desktop.
use std::{env, sync::LazyLock};
pub fn LinkCmakeLibrary(currentBinaryDir: &str, name: &str)
{
const cmakeBinaryDir: &str = env!("STELLAR_CMAKE_BINARY_DIR");
static cmakeConfig: LazyLock<&'static str> = LazyLock::new(|| {
let cargoProfile = env::var("PROFILE").unwrap();
match cargoProfile.as_str() {
"debug" => "Debug",
"release" => "Release",
_ => panic!("Unknown Cargo profile: {cargoProfile}"),
}
});
let targetFileDir =
format!("{cmakeBinaryDir}/{currentBinaryDir}/{}", *cmakeConfig);
println!("cargo::rerun-if-changed={targetFileDir}/{name}.lib");
println!("cargo::rustc-link-search=native={targetFileDir}");
println!("cargo::rustc-link-lib=static={name}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment