Skip to content

Commit 49d82c5

Browse files
committed
Indicate static linker flag for static libraries
1 parent 7a2d4af commit 49d82c5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

build/cmake_probe.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ impl<'r> CmakeProbe<'r> {
159159
}
160160
} else if !arg.starts_with('-') {
161161
let path = Path::new(arg);
162+
let is_static = path.extension().map_or(false, |ext| ext.eq_ignore_ascii_case("a"));
162163
if let Some(file) = path.file_name().and_then(super::cleanup_lib_filename) {
163164
if let Some(parent) = path.parent().map(|p| p.to_owned()) {
164165
if !link_paths.contains(&parent) {
@@ -167,7 +168,12 @@ impl<'r> CmakeProbe<'r> {
167168
} else {
168169
panic!("{}", arg.to_string());
169170
}
170-
link_libs.push(file.to_str().expect("Non-UTF8 filename").to_string());
171+
let file = file.to_str().expect("Non-UTF8 filename");
172+
if is_static {
173+
link_libs.push(format!("static={}", file));
174+
} else {
175+
link_libs.push(file.to_string());
176+
}
171177
}
172178
} else {
173179
eprintln!("=== Unexpected cmake compiler argument found: {arg}");

0 commit comments

Comments
 (0)