Skip to content

Commit 40708f0

Browse files
authored
Merge pull request #17 from Bobo1239/cxx
Add cxxflags analogous to cflags
2 parents 248419f + be1b6eb commit 40708f0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub struct Config {
6262
path: PathBuf,
6363
generator: Option<OsString>,
6464
cflags: OsString,
65+
cxxflags: OsString,
6566
defines: Vec<(OsString, OsString)>,
6667
deps: Vec<String>,
6768
target: Option<String>,
@@ -100,6 +101,7 @@ impl Config {
100101
path: env::current_dir().unwrap().join(path),
101102
generator: None,
102103
cflags: OsString::new(),
104+
cxxflags: OsString::new(),
103105
defines: Vec::new(),
104106
deps: Vec::new(),
105107
profile: None,
@@ -117,14 +119,22 @@ impl Config {
117119
self
118120
}
119121

120-
/// Adds a custom flag to pass down to the compiler, supplementing those
122+
/// Adds a custom flag to pass down to the C compiler, supplementing those
121123
/// that this library already passes.
122124
pub fn cflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config {
123125
self.cflags.push(" ");
124126
self.cflags.push(flag.as_ref());
125127
self
126128
}
127129

130+
/// Adds a custom flag to pass down to the C++ compiler, supplementing those
131+
/// that this library already passes.
132+
pub fn cxxflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config {
133+
self.cxxflags.push(" ");
134+
self.cxxflags.push(flag.as_ref());
135+
self
136+
}
137+
128138
/// Adds a new `-D` flag to pass to cmake during the generation step.
129139
pub fn define<K, V>(&mut self, k: K, v: V) -> &mut Config
130140
where K: AsRef<OsStr>, V: AsRef<OsStr>
@@ -343,7 +353,7 @@ impl Config {
343353
};
344354

345355
set_compiler("C", &c_compiler, &self.cflags);
346-
set_compiler("CXX", &cxx_compiler, &OsString::new());
356+
set_compiler("CXX", &cxx_compiler, &self.cxxflags);
347357
}
348358

349359
if !self.defined("CMAKE_BUILD_TYPE") {

0 commit comments

Comments
 (0)