Skip to content

Commit 63f3cde

Browse files
authored
MSVC: Avoid warning about unknown c++11 option (#43)
MSVC does not offer a C++11 mode, so passing the flag triggers an unknown flag warning. ``` warning: [email protected]: cl : Command line warning D9002 : ignoring unknown option '-std:c++11' ```
1 parent 277ba9c commit 63f3cde

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Remove miniz dependency and replace with libz bindings (or optionally libz-rs)
44
- Update OTS to v0.9.2 (see [upstream ots 0.9.2 release notes])
5+
- Update LZ4 to v1.10.0 (#41)
56

67
[upstream ots 0.9.2 release notes]: https://github.com/khaledhosny/ots/releases/tag/v9.2.0
78

build.rs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,22 @@ fn build_ots() {
2121
.collect::<Result<Vec<PathBuf>, _>>()
2222
.expect("vendored ots sources not found");
2323

24-
cc::Build::new()
24+
let mut builder = cc::Build::new();
25+
26+
builder
2527
.cpp(true)
2628
.files(ots_sources)
2729
.include(OTS_INCLUDE_DIR)
2830
.include(LZ4_INCLUDE_DIR)
2931
.include(WOFF2_INCLUDE_DIR)
30-
.include(ZLIB_INCLUDE_DIR)
31-
.std("c++11")
32-
.compile("ots");
32+
.include(ZLIB_INCLUDE_DIR);
33+
34+
if !builder.get_compiler().is_like_msvc() {
35+
// MSVC does not support C++11 and defaults to C++14.
36+
// The c++11 requirement is taken from the upstream ots meson build.
37+
builder.std("c++11");
38+
}
39+
builder.compile("ots");
3340
}
3441

3542
fn build_brotli() {
@@ -56,23 +63,34 @@ fn build_woff2() {
5663
];
5764
let woff2_sources = file_names.iter().map(|name| woff2_dir.join(name));
5865

59-
cc::Build::new()
66+
let mut builder = cc::Build::new();
67+
68+
builder
6069
.cpp(true)
6170
.files(woff2_sources)
6271
.include(WOFF2_INCLUDE_DIR)
6372
.include(BROTLI_INCLUDE_DIR)
64-
.std("c++11")
65-
.warnings(false)
66-
.compile("woff2");
73+
.warnings(false);
74+
75+
if !builder.get_compiler().is_like_msvc() {
76+
builder.std("c++11");
77+
}
78+
79+
builder.compile("woff2");
6780
}
6881

6982
fn build_ots_glue() {
70-
cc::Build::new()
83+
let mut builder = cc::Build::new();
84+
builder
7185
.cpp(true)
7286
.file("src/ots_glue.cc")
73-
.include(OTS_INCLUDE_DIR)
74-
.std("c++11")
75-
.compile("ots_glue");
87+
.include(OTS_INCLUDE_DIR);
88+
89+
if !builder.get_compiler().is_like_msvc() {
90+
builder.std("c++11");
91+
}
92+
93+
builder.compile("ots_glue");
7694
}
7795

7896
fn main() {

0 commit comments

Comments
 (0)