Skip to content

Commit 7f85e32

Browse files
lthieryalexcrichton
authored andcommitted
Add PIC option (#89)
* try to fix pic issue * set wrong field * formatting
1 parent 8141f0e commit 7f85e32

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub struct Config {
7676
no_build_target: bool,
7777
verbose_cmake: bool,
7878
verbose_make: bool,
79+
pic: Option<bool>,
7980
}
8081

8182
/// Builds the native library rooted at `path` with the default cmake options.
@@ -123,9 +124,16 @@ impl Config {
123124
no_build_target: false,
124125
verbose_cmake: false,
125126
verbose_make: false,
127+
pic: None,
126128
}
127129
}
128130

131+
/// Sets flag for PIC. Otherwise use cc::Build platform default
132+
pub fn pic(&mut self, explicit_flag: bool) -> &mut Config {
133+
self.pic = Some(explicit_flag);
134+
self
135+
}
136+
129137
/// Sets the build-tool generator (`-G`) for this compilation.
130138
pub fn generator<T: AsRef<OsStr>>(&mut self, generator: T) -> &mut Config {
131139
self.generator = Some(generator.as_ref().to_owned());
@@ -345,6 +353,10 @@ impl Config {
345353
c_cfg.static_crt(static_crt);
346354
cxx_cfg.static_crt(static_crt);
347355
}
356+
if let Some(explicit_flag) = self.pic {
357+
c_cfg.pic(explicit_flag);
358+
cxx_cfg.pic(explicit_flag);
359+
}
348360
let c_compiler = c_cfg.get_compiler();
349361
let cxx_compiler = cxx_cfg.get_compiler();
350362
let asm_compiler = c_cfg.get_compiler();

0 commit comments

Comments
 (0)