Skip to content

Commit 49c1f3c

Browse files
committed
Merge branch 'master' of github.com:alexcrichton/cmake-rs into cmake-ios
2 parents 93ff3a1 + 7f85e32 commit 49c1f3c

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
@@ -81,6 +81,7 @@ pub struct Config {
8181
no_build_target: bool,
8282
verbose_cmake: bool,
8383
verbose_make: bool,
84+
pic: Option<bool>,
8485
}
8586

8687
/// Builds the native library rooted at `path` with the default cmake options.
@@ -128,9 +129,16 @@ impl Config {
128129
no_build_target: false,
129130
verbose_cmake: false,
130131
verbose_make: false,
132+
pic: None,
131133
}
132134
}
133135

136+
/// Sets flag for PIC. Otherwise use cc::Build platform default
137+
pub fn pic(&mut self, explicit_flag: bool) -> &mut Config {
138+
self.pic = Some(explicit_flag);
139+
self
140+
}
141+
134142
/// Sets the build-tool generator (`-G`) for this compilation.
135143
pub fn generator<T: AsRef<OsStr>>(&mut self, generator: T) -> &mut Config {
136144
self.generator = Some(generator.as_ref().to_owned());
@@ -351,6 +359,10 @@ impl Config {
351359
c_cfg.static_crt(static_crt);
352360
cxx_cfg.static_crt(static_crt);
353361
}
362+
if let Some(explicit_flag) = self.pic {
363+
c_cfg.pic(explicit_flag);
364+
cxx_cfg.pic(explicit_flag);
365+
}
354366
let c_compiler = c_cfg.get_compiler();
355367
let cxx_compiler = cxx_cfg.get_compiler();
356368
let asm_compiler = c_cfg.get_compiler();

0 commit comments

Comments
 (0)