Commit 4a288ab9 by Henry Schreiner Committed by GitHub

fix: Windows C++ latest (#2508)

parent 87828c7e
...@@ -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)):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment