I am working on a project that uses Bazel, but some of the external dependencies only support cmake. In particular, I am trying to get https://github.com/google/ukey2 to work. However, I keep running into the missing file problem. Basically my projects depends on ukey2, which depends on protobuf (
https://github.com/google/ukey2/tree/master/third_party), but somehow the protobuf directory is not getting populated. I tried passing in " -Dprotobuf_BUILD_TESTS=OFF", but somehow the tests are still being run.
Any idea what is going on and how to fix it?
--------------- error message -----------
CMake Error at tests.cmake:2 (message):
Cannot find third_party/googletest directory that's needed to build tests.
If you use git, make sure you have cloned submodules:
git submodule update --init --recursive
If instead you want to skip tests, run cmake with:
cmake -Dprotobuf_BUILD_TESTS=OFF
-------------
--- I use new_git_repository in WORKSPACE to clone all the submodules recursively ---
new_git_repository(
name = "com_google_ukey2",
branch = "master",
build_file_content = _ALL_CONTENT,
init_submodules = True,
recursive_init_submodules = True,
)
---------------
---- Bazel BUILD file --------
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
cmake(
name = "ukey2",
cache_entries = {
"CMAKE_CXX_FLAGS": "-std=c++11 -Dprotobuf_BUILD_TESTS=OFF",
},
generate_args = [
"-Dukey2_USE_LOCAL_PROTOBUF=ON",
"-Dukey2_USE_LOCAL_ABSL=ON",
"-Dprotobuf_BUILD_TESTS=OFF",
],
lib_source = "@com_google_ukey2//:all_srcs",
linkopts = ["-pthread -Dprotobuf_BUILD_TESTS=OFF"],
out_static_libs = ["libukey2.a"],
)
----------