Skip to content

Commit 69a8f61

Browse files
committed
fix: use ninja generator for cmake builds [DIP-311]
1 parent 9924b81 commit 69a8f61

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

cc/toolchains/llvm/unix_cc_toolchain_config.bzl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ load(
2929
)
3030
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
3131

32+
def _target_os_version(ctx):
33+
platform_type = ctx.fragments.apple.single_arch_platform.platform_type
34+
xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig]
35+
return xcode_config.minimum_os_for_platform_type(platform_type)
36+
3237
def layering_check_features(compiler):
3338
if compiler != "clang":
3439
return []
@@ -1283,6 +1288,17 @@ def _impl(ctx):
12831288
],
12841289
)
12851290

1291+
macos_minimum_os_feature = feature(
1292+
name = "macos_minimum_os",
1293+
enabled = True,
1294+
flag_sets = [
1295+
flag_set(
1296+
actions = all_compile_actions + all_link_actions,
1297+
flag_groups = [flag_group(flags = ["-mmacos-version-min={}".format(_target_os_version(ctx))])],
1298+
),
1299+
],
1300+
)
1301+
12861302
is_linux = ctx.attr.target_libc != "macosx"
12871303
libtool_feature = feature(
12881304
name = "libtool",
@@ -1365,6 +1381,7 @@ def _impl(ctx):
13651381
asan_feature,
13661382
tsan_feature,
13671383
ubsan_feature,
1384+
macos_minimum_os_feature,
13681385
] + (
13691386
[
13701387
supports_start_end_lib_feature,
@@ -1431,6 +1448,11 @@ cc_toolchain_config = rule(
14311448
"coverage_link_flags": attr.string_list(),
14321449
"supports_start_end_lib": attr.bool(),
14331450
"builtin_sysroot": attr.string(),
1451+
"_xcode_config": attr.label(default = configuration_field(
1452+
fragment = "apple",
1453+
name = "xcode_config_label",
1454+
)),
14341455
},
1456+
fragments = ["apple"],
14351457
provides = [CcToolchainConfigInfo],
14361458
)

third_party/check.BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ cmake(
3030
"-lrt",
3131
],
3232
}),
33+
generate_args = [
34+
"-GNinja",
35+
"-DCMAKE_OSX_DEPLOYMENT_TARGET=13.0",
36+
],
3337
out_static_libs = select({
3438
"@bazel_tools//src/conditions:windows": ["check.lib"],
3539
"//conditions:default": ["libcheck.a"],

third_party/nlopt.BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ cmake(
2626
"CMAKE_INSTALL_LIBDIR": "lib",
2727
},
2828
generate_args = [
29+
"-GNinja",
30+
"-DCMAKE_OSX_DEPLOYMENT_TARGET=13.0",
2931
"-DBUILD_SHARED_LIBS=OFF",
3032
"-DNLOPT_PYTHON=OFF",
3133
"-DNLOPT_OCTAVE=OFF",

0 commit comments

Comments
 (0)