diff --git a/tycho/CMakeLists.txt b/tycho/CMakeLists.txt index 564ad39..7f684f1 100644 --- a/tycho/CMakeLists.txt +++ b/tycho/CMakeLists.txt @@ -73,6 +73,16 @@ target_compile_definitions( -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT ) +file( + GENERATE + OUTPUT link.txt + CONTENT +"$ +$ +$" +) + install(TARGETS maraiah-tycho-hermes) +install(FILES ${CMAKE_BINARY_DIR}/link.txt TYPE SYSCONF) ## EOF diff --git a/tycho/build.rs b/tycho/build.rs index 9339642..4dd8311 100644 --- a/tycho/build.rs +++ b/tycho/build.rs @@ -1,5 +1,5 @@ use rust_qt_binding_generator::*; -use std::path::PathBuf; +use std::{io::prelude::*, path::PathBuf}; fn main() { @@ -21,13 +21,42 @@ fn main() let out_dir = config.build(); let lib_dir = out_dir.join("lib"); + let etc_dir = out_dir.join("etc"); println!("cargo:rustc-link-search=native={}", lib_dir.display()); println!("cargo:rustc-link-lib=static=maraiah-tycho-hermes"); - println!("cargo:rustc-link-lib=dylib=Qt5Core"); - println!("cargo:rustc-link-lib=dylib=Qt5Widgets"); - println!("cargo:rustc-link-lib=dylib=Qt5Gui"); - println!("cargo:rustc-link-lib=dylib=stdc++"); + + let fp = std::fs::File::open(etc_dir.join("link.txt")).unwrap(); + let fp = std::io::BufReader::new(fp); + + for ln in fp.lines() { + let ln = ln.unwrap(); + + let path = PathBuf::from(&ln); + let path = path.parent().unwrap(); + + let (ty, path) = if cfg!(target_os = "macos") { + ("framework", path.parent().unwrap()) + } else { + ("native", path) + }; + + println!("cargo:rustc-link-search={}={}", ty, path.display()); + } + + let (ty, pre) = if cfg!(target_os = "macos") { + ("framework", "Qt") + } else { + ("dylib", "Qt5") + }; + + println!("cargo:rustc-link-lib={}={}Core", ty, pre); + println!("cargo:rustc-link-lib={}={}Widgets", ty, pre); + println!("cargo:rustc-link-lib={}={}Gui", ty, pre); + + if !cfg!(target_os = "macos") { + println!("cargo:rustc-link-lib=dylib=stdc++"); + } } // EOF