From 0771084b5475a560ccdc03e6fa0e3c30f95dd638 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Sat, 24 Jun 2023 19:55:26 +0200 Subject: [SCons] Simplify building cmake libraries. Add an extra "CMakeBuild" method to reduce configuration needed by each library. --- tools/cmake.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools/cmake.py') diff --git a/tools/cmake.py b/tools/cmake.py index c590860..39957d8 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -101,6 +101,18 @@ def cmake_generator(target, source, env, for_signature): ] +def cmake_build(env, target_dir, source_dir, cmake_outputs=[], cmake_targets=[], cmake_options=[], dependencies=[]): + cmake_env = env.Clone() + target = env.Dir("{}/{}/{}".format(target_dir, env["platform"], env["arch"])) + source = env.Dir(source_dir) + builder_targets = [target] + [str(target) + "/" + f for f in cmake_outputs] + builder_sources = [source] + dependencies + cmake_env.Append(CMAKECONFFLAGS=["-D%s=%s" % it for it in cmake_options.items()]) + if len(cmake_targets) > 0: + cmake_env.Append(CMAKEBUILDFLAGS=["-t"] + [t for t in cmake_targets]) + return cmake_env.CMake(builder_targets, builder_sources) + + def options(opts): opts.Add("cmake_default_flags", "Default CMake platform flags override, will be autodetected if not specified.", "") @@ -120,3 +132,4 @@ def generate(env): env["CMAKEBUILDFLAGS"] = SCons.Util.CLVar("") env["CMAKEBUILDCOM"] = "$CMAKE --build ${TARGET.dir} $CMAKEBUILDFLAGS -j$CMAKEBUILDJOBS" env["BUILDERS"]["CMake"] = SCons.Builder.Builder(generator=cmake_generator, emitter=cmake_emitter) + env.AddMethod(cmake_build, "CMakeBuild") -- cgit v1.2.3