-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake support #29
Comments
No one specifically asked for it previously so it wasn't a priority. But it sounds like there is some interest now so we will try to prioritize. Probably we will need to create a system to auto-convert the Bazel build rules into CMake rules, which should be fairly straightforward. The hardest part will be dealing with getting all of the dependencies available through cmake as well. |
Can you tell me more about why cmake support is useful to you? It's a pretty large step to take given the current dependency set. |
I want to add Zarr support to https://github.com/InsightSoftwareConsortium/ITK. ITK's build system is CMake-based, so a library needs to be CMake-ified in order for us to use it. I already got started, relying on |
Thanks for contributing the tensorstore! My use cases for cmake are one, I want to be able to just compile tensorstore and use it as a library with other projects that are already using cmake. And a far second, I haven't been able to get the intellisense and debuggers working with Bazel in VSCode. I haven't used Bazel before so it could be these things are easy to do. You right though, supporting a whole new build system does seem like a pretty big lift. Is there anyway I could help out if you decided to do that? |
Maybe this repo could serve as a starting point. |
Sure, I'm aware of @haberman's repo there. I have actually started doing something based on very similar concepts, so a preliminary, incomplete CMake framework should be visible whenever we do the next export. The main issues that I've run into so far are:
So if you would like to help this happen, look at the dependencies under third_party and see which ones don't have CMake support; that's what has to happen next. |
This seems biased, so I'll disregard. I do sympathize with your frustration in porting to a different build system though. That said, I know CMake (syntax seems similar to Lua which is not ideal for OOP) far better than I understand how to use Bazel (which is not at all). I think an argument could be made about python's execution speed (used in Bazel) vs CMake's native execution speed, but this is getting off-topic...
My experience with CMake is that their Some scenarios may be satisfied by CMake-provided "Find Modules" shipped with CMake (be mindful of the CMake version specified). Typically, if acquiring a dependency is not satisfied by these builtin modules, then it is pretty common for software devs to write their own "Find Module" (see the tutorial here). I understand how this convention is undesirable here since you prefer to only support the Bazel system, but if the find module(s) is written well, then it could be a set-and-forget tactic. I don't really have a use case for this lib; I landed here out of curiosity via reference from @jbms. I just thought I could pass along what I've learned from working with CMake/pybind11 in the past. Please don't take offense if I don't volunteer contributions. I'm staying subscribed to this issue so my comments won't be "drive-by" observations. |
Yes, my opinion that cmake is not a good language is totally subjective. But that's my experience so far. And a lot of other folks share it: https://news.ycombinator.com/item?id=25701041 But it has become a key integration point, however I view it. I've been trying to use the newer functionality of FetchContent and friends, which also maintains a somewhat hermetic build when coupled with our existing bazel dependency downloading, but the sticking point right now is dependencies that are not exposed via cmake. Thanks for the recommendations, I may need to use them at some point. |
Sorry, I didn't realize that Bazel was downloading deps. That seems like an alternative to using git submodules, but it is better for pip installing a C-ext from sdist. Thanks for that FetchContent lead. |
I've added preliminary CMake generation; it's not ready yet, but anyone is free to play with it and maybe update it:
NOTE: This will not yet build tensorstore. |
I am starting a vacation + conference trip tomorrow, so I will not be able to devote significant effort to this until July. How important is requirement of C++17 standard? In ITK, we are just about to release a version after switching from C++11 to C++14. Trying cmake configure yields:
Notably:
This means I can't build it on my main machine yet. |
C++17 is definitely required. I believe the cmake support is still a work in progress and not yet expected to actually work. |
One more reason for us to move to C++17 sooner, rather than later. As we plan for Zarr/NGFF IO implementation to live in a repository separate from the main one, we can implicitly require C++17 only if Zarr/NGFF is enabled. |
I remember having trouble building BoringSSL a few years ago as part of GRPC. I eventually got it, but it wasn't quite so boring 😄 |
Echoing jbms@, this does not yet build tensorstore, particularly since some of the dependencies don't yet work with CMake. Also, the CMake build will require NASM, among other things, and it will not install NASM. |
Not sure if will help with fetching external deps, but I found a project (written in python) called conan which makes installing C++ libs easy. They even have a conan.cmake script for integration with cmake builds. |
Using the python bazel to cmake command, I was seeing an error, error: Missing mapping for @com_google_absl//absl/flags:marshalling in tensorstore/kvstore/gcs/BUILD I made the following change to line 60 of com_google_absl/workspace.bzl
Seems to help. |
I can do that. cmake changes have stalled for other work, but if you make progress I can probably incorporate your changes quickly. |
thanks, the converter does create CMakeLists.txt and the build progresses. Right now it gets through building abseil and some of the other dependencies and then falls over with riegeli library, which itself seems to be a library built using Bazel. That might be the source of the problem. Of the tensorstore third party libraries, riegeli and upd require Bazel to build. The error in the "make" is here: fatal error: riegeli/bytes/writer.h: No such file or directory |
Seems about right. I was going to try to apply my cmake generator to riegeli, but hadn't gotten that far yet. |
I am also working on a project that will be greatly benefited if I can get the build system in CMake working. I am a relatively new dev, but if you can point to places to work on, I have some spare time to contribute for the CMake based build system. |
@sameeul I can share my experience. The python bazel_to_cmake.py generated the CMakeLists.txt for tensorstore. The issues I had were:
With these fixes, excluding a minority of tests, the library builds. There's a linking error I'm following up on. |
FWIW in third_party/com_google_googletest/workspace.bzl I changed the cmake mappings to point to gmock instead of gtest. The issue was that while linking, some of the tests couldn't find some symbols like UnorderedElementsAreMatcherImplBase which are in libgmock.a. Seems to resolve the issue. Updated workspace.bzl reads: |
The driver tests were building, but they were failing at runtime due to errors related to registering the various drivers (zarr, blosc, etc). By manually editing the SRCS section in the CMakeLists.txt (for example in the zarr folder), the issue was resolved and the test passed. Additional lines adding under sources, below zarr/driver_test.cc. tensorstore_cc_test( |
I believe the issue with the registration is that the cmake generation needs to take into account the bazel |
alwayslink seems like it may be tricky in CMake. I'm not sure what the best solution is --- see iree-org/iree#190 |
Great progress though in getting the build to this point, thanks! |
Actually, it appears CMake now has built-in support for this: https://discourse.cmake.org/t/automatically-wrapping-a-static-library-in-whole-archive-no-whole-archive-when-used-during-linking/5883 |
What is the current status? Is there any branch of code to try? |
We still need to incorporate some of the suggestions made by @blasscoc to get it building and fix the always_link issue. |
quick update; using: Generates errors like this: absl, nlohmann_json (possible others involved). Is there a way to fix this? I've tried install abseil in the system path and using find_package(absl CONFIG REQUIRED) like here: This does solve the EXPORT error but I run into other problems. |
This is now complete. |
This was written more than 2 years ago. The future is here, where is CMake support? 😄
Seriously, is there some plan or a timeline?
The text was updated successfully, but these errors were encountered: