Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
4a288ab9
Unverified
Commit
4a288ab9
authored
Sep 18, 2020
by
Henry Schreiner
Committed by
GitHub
Sep 18, 2020
Browse files
fix: Windows C++ latest (#2508)
parent
87828c7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
pybind11/setup_helpers.py
pybind11/setup_helpers.py
+18
-7
No files found.
pybind11/setup_helpers.py
View file @
4a288ab9
...
@@ -156,7 +156,8 @@ class Pybind11Extension(_Extension):
...
@@ -156,7 +156,8 @@ class Pybind11Extension(_Extension):
if
self
.
_cxx_level
:
if
self
.
_cxx_level
:
warnings
.
warn
(
"You cannot safely change the cxx_level after setting it!"
)
warnings
.
warn
(
"You cannot safely change the cxx_level after setting it!"
)
# MSVC 2015 Update 3 and later only have 14 (and later 17) modes
# MSVC 2015 Update 3 and later only have 14 (and later 17) modes, so
# force a valid flag here.
if
WIN
and
level
==
11
:
if
WIN
and
level
==
11
:
level
=
14
level
=
14
...
@@ -168,15 +169,22 @@ class Pybind11Extension(_Extension):
...
@@ -168,15 +169,22 @@ class Pybind11Extension(_Extension):
self
.
extra_compile_args
.
append
(
STD_TMPL
.
format
(
level
))
self
.
extra_compile_args
.
append
(
STD_TMPL
.
format
(
level
))
if
MACOS
and
"MACOSX_DEPLOYMENT_TARGET"
not
in
os
.
environ
:
if
MACOS
and
"MACOSX_DEPLOYMENT_TARGET"
not
in
os
.
environ
:
# C++17 requires a higher min version of macOS
# C++17 requires a higher min version of macOS. An earlier version
# can be set manually via environment variable if you are careful
# in your feature usage, but 10.14 is the safest setting for
# general use.
macosx_min
=
"-mmacosx-version-min="
+
(
"10.9"
if
level
<
17
else
"10.14"
)
macosx_min
=
"-mmacosx-version-min="
+
(
"10.9"
if
level
<
17
else
"10.14"
)
self
.
extra_compile_args
.
append
(
macosx_min
)
self
.
extra_compile_args
.
append
(
macosx_min
)
self
.
extra_link_args
.
append
(
macosx_min
)
self
.
extra_link_args
.
append
(
macosx_min
)
if
PY2
:
if
PY2
:
if
level
>=
17
:
if
WIN
:
self
.
extra_compile_args
.
append
(
"/wd5033"
if
WIN
else
"-Wno-register"
)
# Will be ignored on MSVC 2015, where C++17 is not supported so
elif
not
WIN
and
level
>=
14
:
# this flag is not valid.
self
.
extra_compile_args
.
append
(
"/wd5033"
)
elif
level
>=
17
:
self
.
extra_compile_args
.
append
(
"-Wno-register"
)
elif
level
>=
14
:
self
.
extra_compile_args
.
append
(
"-Wno-deprecated-register"
)
self
.
extra_compile_args
.
append
(
"-Wno-deprecated-register"
)
...
@@ -227,9 +235,12 @@ cpp_flag_cache = None
...
@@ -227,9 +235,12 @@ cpp_flag_cache = None
def
auto_cpp_level
(
compiler
):
def
auto_cpp_level
(
compiler
):
"""
"""
Return the max supported C++ std level (17, 14, or 11).
Return the max supported C++ std level (17, 14, or 11).
Returns latest on Windows.
"""
"""
if
WIN
:
return
"latest"
global
cpp_flag_cache
global
cpp_flag_cache
# If this has been previously calculated with the same args, return that
# If this has been previously calculated with the same args, return that
...
@@ -237,7 +248,7 @@ def auto_cpp_level(compiler):
...
@@ -237,7 +248,7 @@ def auto_cpp_level(compiler):
if
cpp_flag_cache
:
if
cpp_flag_cache
:
return
cpp_flag_cache
return
cpp_flag_cache
levels
=
[
17
,
14
]
+
([]
if
WIN
else
[
11
]
)
levels
=
[
17
,
14
,
11
]
for
level
in
levels
:
for
level
in
levels
:
if
has_flag
(
compiler
,
STD_TMPL
.
format
(
level
)):
if
has_flag
(
compiler
,
STD_TMPL
.
format
(
level
)):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment