mirror of
https://github.com/bazel-contrib/rules_foreign_cc
synced 2024-11-30 16:42:07 +00:00
e36f3cee8c
Fix #232 - enable usage of Bazel-built libraries as dependencies of cmake_external and configure_make. - fix logic of reading library data described by C/C++ Bazel interface (as CcInfo.linking_context appeared) - symlink transitive include directories under $EXT_BUILD_DEPS - gather all possible transitive include directories to pass to CMake, pass transitive include directories to CMAKE_PREFIX_PATH so that the transitive include directories were scanned by CMake - fix logic of passing transitive libraries into CPPFLAGS (configure_make) - add test with the chain: Bazel lib -> CMake lib -> Bazel cc_test - add synthetic configure-make test with the chain: Bazel lib -> configure_make lib -> Bazel cc_test - also notice, that passed include directories from Bazel C/C++ Sandwich interface are not always existing; for now, make symlinking code resistant to that see https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Preset-Output-Variables.html
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")
|
|
|
|
# Example of the cmake_external target built with Bazel-built dependency
|
|
cmake_external(
|
|
name = "cmake_libb",
|
|
cache_entries = {
|
|
# as currently we copy all libraries, built with Bazel, into $EXT_BUILD_DEPS/lib
|
|
# and the headers into $EXT_BUILD_DEPS/include
|
|
"LIBA_DIR": "$EXT_BUILD_DEPS",
|
|
# CMake's find_package wants to find cmake config for liba,
|
|
# which we do not have -> disable search
|
|
"CMAKE_DISABLE_FIND_PACKAGE_LIBA": "True",
|
|
},
|
|
cmake_options = ["-GNinja"],
|
|
lib_source = "//cmake_with_bazel_transitive/libb:b_srcs",
|
|
make_commands = [
|
|
"ninja",
|
|
"ninja install",
|
|
],
|
|
static_libraries = ["libb.a"],
|
|
# This library is with public visibility, we can reuse it here.
|
|
deps = ["//cmake_synthetic/liba:lib_a_bazel"],
|
|
)
|
|
|
|
# And cc_test built with cmake_external dependency and transitive Bazel dependency
|
|
cc_test(
|
|
name = "test",
|
|
srcs = [
|
|
"test_libb.cpp",
|
|
],
|
|
deps = [
|
|
# liba should come from transitive dependencies
|
|
":cmake_libb",
|
|
],
|
|
)
|