2021-01-25 22:01:43 +00:00
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_test")
|
2021-03-09 18:55:01 +00:00
|
|
|
load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake")
|
2021-01-25 15:44:44 +00:00
|
|
|
|
2021-03-09 18:55:01 +00:00
|
|
|
cmake(
|
2021-01-25 15:44:44 +00:00
|
|
|
name = "cmake_with_data",
|
|
|
|
cache_entries = select({
|
|
|
|
"@bazel_tools//src/conditions:windows": {
|
|
|
|
"CMAKE_BUILD_TYPE": "Release",
|
2021-02-16 19:55:48 +00:00
|
|
|
"CMAKE_CXX_FLAGS": "/MD",
|
|
|
|
"CMAKE_CXX_FLAGS_DEBUG": "/MD",
|
2021-01-25 15:44:44 +00:00
|
|
|
},
|
|
|
|
"//conditions:default": {},
|
|
|
|
}),
|
|
|
|
cmake_options = select({
|
|
|
|
"@bazel_tools//src/conditions:windows": ["-G \"Visual Studio 15 2017\" -A x64"],
|
|
|
|
"//conditions:default": [],
|
|
|
|
}),
|
|
|
|
data = [
|
|
|
|
"cmake_with_data.txt",
|
|
|
|
"//cmake_with_data/lib_b",
|
|
|
|
],
|
|
|
|
lib_source = "//cmake_with_data/lib_a:srcs",
|
|
|
|
make_commands = select({
|
|
|
|
"@bazel_tools//src/conditions:windows": ["MSBuild.exe INSTALL.vcxproj"],
|
2021-01-25 22:01:43 +00:00
|
|
|
"//conditions:default": [
|
|
|
|
"make",
|
|
|
|
"make install",
|
|
|
|
],
|
2021-01-25 15:44:44 +00:00
|
|
|
}),
|
2021-03-11 17:14:00 +00:00
|
|
|
out_static_libs = select({
|
2021-01-25 15:44:44 +00:00
|
|
|
"@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",
|
|
|
|
],
|
|
|
|
)
|