Skip to content

Add c++20 support #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions robotpy_build/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ def has_flag(compiler, flagname):


def cpp_flag(compiler, pfx, sep="="):
"""Return the -std=c++[11/14/17] compiler flag.
"""Return the -std=c++[11/14/17/20] compiler flag.
The newer version is prefered over c++11 (when it is available).
"""

flags = [f"{pfx}std{sep}c++17", f"{pfx}std{sep}c++14", f"{pfx}std{sep}c++11"]
flags = [
f"{pfx}std{sep}c++20",
f"{pfx}std{sep}c++17",
f"{pfx}std{sep}c++14",
f"{pfx}std{sep}c++11",
]

for flag in flags:
if has_flag(compiler, flag):
Expand Down Expand Up @@ -75,6 +80,7 @@ def build_extensions(self):
opts.append("-fvisibility=hidden")
elif ct == "msvc":
opts.append(cpp_flag(self.compiler, "/", ":"))
opts.append("/Zc:__cplusplus")
for ext in self.extensions:
ext.define_macros.append(("PYBIND11_USE_SMART_HOLDER_AS_DEFAULT", "1"))
ext.extra_compile_args = opts
Expand Down