Skip to content

Commit a274ac0

Browse files
authored
add cmake configuration attr (#1339)
`cmake()` appends a `--config` arg to every `cmake --install` and `cmake --build`. The default value of this arg is derived from the COMPILATION_MODE env var. This PR allows `cmake()` to override this value.
1 parent 6491a0c commit a274ac0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

foreign_cc/cmake.bzl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ def _create_configure_script(configureParameters):
206206

207207
cmake_commands = []
208208

209-
configuration = "Debug" if is_debug_mode(ctx) else "Release"
209+
default_configuration = "Debug" if is_debug_mode(ctx) else "Release"
210+
configuration = default_configuration if not ctx.attr.configuration else ctx.attr.configuration
210211

211212
data = ctx.attr.data + ctx.attr.build_data
212213

@@ -365,6 +366,15 @@ def _attrs():
365366
mandatory = False,
366367
default = {},
367368
),
369+
"configuration": attr.string(
370+
doc = (
371+
"Override the `cmake --build` and `cmake --install` `--config` configuration. " +
372+
"If left empty, the value of this arg will be determined by the COMPILATION_MODE env var: " +
373+
"dbg will set `--config Debug` and all other modes will set --config Release."
374+
),
375+
mandatory = False,
376+
default = "",
377+
),
368378
"generate_args": attr.string_list(
369379
doc = (
370380
"Arguments for CMake's generate command. Arguments should be passed as key/value pairs. eg: " +

0 commit comments

Comments
 (0)