From f81e68ee02493d04da08673362693bfca32813e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Brand=C3=A3o?= Date: Fri, 23 Feb 2024 12:42:48 +0000 Subject: [PATCH] setup.py: Set platform specific compiler arguments --- nl-writer2/setup.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/nl-writer2/setup.py b/nl-writer2/setup.py index 57c0b144b..87e14e5fb 100644 --- a/nl-writer2/setup.py +++ b/nl-writer2/setup.py @@ -15,11 +15,36 @@ # Sort input source files if you glob sources to ensure bit-for-bit # reproducible builds (https://github.com/pybind/python_example/pull/53) + +def compile_args(): + from platform import system + + if system() == "Windows": + return ["/std:c++17"] + elif system() == "Linux": + ignore_warnings = [ + "-Wno-stringop-truncation", + "-Wno-catch-value", + "-Wno-unused-variable", + ] + return ["-std=c++17"] + ignore_warnings + elif system() == "Darwin": + ignore_warnings = [ + "-Wno-unused-variable", + ] + return [ + "-std=c++17", + "-mmacosx-version-min=10.15", + ] + ignore_warnings + else: + return [] + + ext_modules = [ Extension( "nlwpy", ["nlwpy/src/nlw_bindings.cc"] + glob.glob("./src/" + "*.cc"), - # extra_compile_args=["-std=c++17"], - need all platforms + extra_compile_args=compile_args(), include_dirs=["include", pybind11.get_include()], # Example: passing in the version to the compiled code define_macros=[("VERSION_INFO", __version__)],