diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-06-05 21:55:24 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-06-17 19:46:54 +0200 |
commit | 61299ca4b7390b5391d9ee6b6a82e2c30271dd3a (patch) | |
tree | 0325bbc311e75089d9ad8c403bb81a8a6b225a5d /tools/cmake.py | |
parent | df643250f5e35d5ecbbd6dafab940a4e7e4d2f25 (diff) | |
download | fork-godot-webrtc-native-61299ca4b7390b5391d9ee6b6a82e2c30271dd3a.tar.gz fork-godot-webrtc-native-61299ca4b7390b5391d9ee6b6a82e2c30271dd3a.tar.bz2 fork-godot-webrtc-native-61299ca4b7390b5391d9ee6b6a82e2c30271dd3a.zip |
[SCons] Refactor build system.
Update ssl tool (now renamed openssl).
Move universal library "lipo" action to openssl tool, and add universal
builds support to cmake tool.
Add support for MSVC builds (requires nasm and perl in PATH, tested with
Strawberry Perl, VS 2019 and VS 2022).
Add support for building "macos" via OSXCross.
Diffstat (limited to 'tools/cmake.py')
-rw-r--r-- | tools/cmake.py | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/tools/cmake.py b/tools/cmake.py index d552da6..5b05d15 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -1,4 +1,4 @@ -import os +import os, sys def exists(env): @@ -16,17 +16,27 @@ def cmake_configure(env, source, target, opt_args): "-B", target, ] - if env["platform"] == "windows" and env["use_mingw"]: - args.extend(["-G", "Unix Makefiles"]) + + if env["platform"] == "windows": + if env.get("is_msvc", False): + args.extend(["-G", "NMake Makefiles"]) + elif sys.platform in ["win32", "msys", "cygwin"]: + args.extend(["-G", "Ninja"]) + else: + args.extend(["-G", "Unix Makefiles"]) + for arg in opt_args: args.append(arg) args.append(source) return env.Execute("cmake " + " ".join(['"%s"' % a for a in args])) -def cmake_build(env, source, target=""): +def cmake_build(env, source, target="", opt_args=[]): jobs = env.GetOption("num_jobs") - return env.Execute("cmake --build %s %s -j%s" % (source, "-t %s" % target if target else "", jobs)) + return env.Execute( + "cmake --build %s %s -j%s %s" + % (source, "-t %s" % target if target else "", jobs, " ".join(['"%s"' % a for a in opt_args])) + ) def cmake_platform_flags(env, config=None): @@ -62,11 +72,24 @@ def cmake_platform_flags(env, config=None): elif env["platform"] == "macos": if env["arch"] == "universal": - raise ValueError("OSX architecture not supported: %s" % env["arch"]) - config["CMAKE_OSX_ARCHITECTURES"] = env["arch"] + config["CMAKE_OSX_ARCHITECTURES"] = "x86_64;arm64" + else: + config["CMAKE_OSX_ARCHITECTURES"] = env["arch"] if env["macos_deployment_target"] != "default": config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"] + if env["platform"] == "macos" and sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ: + config["CMAKE_AR"] = env["AR"] + config["CMAKE_RANLIB"] = env["RANLIB"] + if env["arch"] == "universal": + flags = "-arch x86_64 -arch arm64" + else: + flags = "-arch " + env["arch"] + if env["macos_deployment_target"] != "default": + flags += " -mmacosx-version-min=" + env["macos_deployment_target"] + config["CMAKE_C_FLAGS"] = flags + config["CMAKE_CXX_FLAGS"] = flags + elif env["platform"] == "ios": if env["arch"] == "universal": raise ValueError("iOS architecture not supported: %s" % env["arch"]) |