diff --git a/rustcord-sys/build.rs b/rustcord-sys/build.rs index 9f0f7df..bf6e8b9 100644 --- a/rustcord-sys/build.rs +++ b/rustcord-sys/build.rs @@ -1,17 +1,21 @@ use std::env; use std::path::PathBuf; -const LIB_VERSION: &str = "3.4.0"; - fn main() { - let config = cmake::Config::new("discord-rpc".to_string()) + let dst = cmake::Config::new("discord-rpc") .define("BUILD_EXAMPLES", "OFF") .build(); - println!("cargo:rustc-link-search={}", config.join("lib").display()); - println!("cargo:rustc-link-search={}", config.join("lib64").display()); + println!( + "cargo:rustc-link-search={}", + dst.join("lib").display() + ); + println!( + "cargo:rustc-link-search={}", + dst.join("lib64").display() + ); - let include_path = format!("discord-rpc-{}/include", LIB_VERSION); + let include_path = "discord-rpc/include".to_string(); let bindings = bindgen::Builder::default() .header("wrapper.h") @@ -25,4 +29,13 @@ fn main() { .expect("Couldn't write bindings!"); println!("cargo:rustc-link-lib=static=discord-rpc"); + + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + + match target_os.as_str() { + "linux" => println!("cargo:rustc-link-lib=dylib=stdc++"), + "macos" => println!("cargo:rustc-link-lib=dylib=c++"), + "windows" => {}, + _ => panic!("Unsupported platform!"), + } } diff --git a/rustcord-sys/wrapper.h b/rustcord-sys/wrapper.h index f7cc8e2..6d88b6c 100644 --- a/rustcord-sys/wrapper.h +++ b/rustcord-sys/wrapper.h @@ -1 +1 @@ -#include "discord-rpc/include/discord_rpc.h" \ No newline at end of file +#include