2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-11-30 16:42:07 +00:00
rules_foreign_cc/examples/cmake_with_data/BUILD.bazel
UebelAndre e4399415b8
Added "targets" API (#556)
* Added `targets` API to all existing build rules

* Updated examples

* Restore making the make toolchain always available.

* Add support for generator cmake parsing and setting CMAKE_MAKE_PROGRAM

* Cleaned up duplicate generator arguments

* Fixed cmake tests

* Updated docs

* Addressed PR feedback

* Fixed missing and incorrect generators

* Fixed `generate_args` name
2021-03-17 13:42:44 +00:00

61 lines
1.4 KiB
Python

load("@rules_cc//cc:defs.bzl", "cc_test")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
cmake(
name = "cmake_with_data",
cache_entries = select({
"@bazel_tools//src/conditions:windows": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_FLAGS": "/MD",
"CMAKE_CXX_FLAGS_DEBUG": "/MD",
},
"//conditions:default": {},
}),
data = [
"cmake_with_data.txt",
"//cmake_with_data/lib_b",
],
generate_args = select({
"@bazel_tools//src/conditions:windows": [
"-G \"Visual Studio 15 2017\"",
"-A x64",
],
"//conditions:default": [],
}),
lib_source = "//cmake_with_data/lib_a:srcs",
out_static_libs = select({
"@bazel_tools//src/conditions:windows": ["lib_a.lib"],
"//conditions:default": ["lib_a.a"],
}),
)
# Demonstrates that files can be made available at runtime
cc_test(
name = "test_with_data",
srcs = [
"tests/test_cmake_with_data.cpp",
],
deps = [
":cmake_with_data",
],
)
# Demonstrates that target outputs can be made available at runtime
cc_test(
name = "test_with_shared_lib",
srcs = [
"tests/test_cmake_with_shared_lib.cpp",
],
deps = [
":cmake_with_data",
],
)
test_suite(
name = "data_attr_tests",
tests = [
":test_with_data",
":test_with_shared_lib",
],
)