-
Notifications
You must be signed in to change notification settings - Fork 17
Switch from Autotools to CMake for fitsio-sys #398
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
base: main
Are you sure you want to change the base?
Conversation
When cross-compiling to multiple architectures, fitsio-sys using the Autotools path leads to build failures: the generated Makefile only supports building CFITSIO into the source directory, i.e., a directory within ~/.cargo most of the time. When separate builds need fitsio-sys built for different architectures, this leads to file collisions and (eventually) link errors. Fortunately, CFITSIO has a CMake-based build path, and we switch to using it in this commit. It did require a one-line fix in CMakeLists.txt, which is included.
The CMake-based build puts the static library and include files in subdirectories of the path retured by Config::build(); this commit compensates accordingly.
This, as it turns out, is the behavior followed by the Autotools build of CFITSIO.
Is it possiable to support MSVC native compile on Windows platform? Compared with autotools, CMake is cross platfrom supported includes native MSVC. |
That is supported by the [1] https://docs.rs/cmake/0.1.54/cmake/struct.Config.html#method.generator |
Thanks for posting this PR. I am not convinced replacing one build system with another is the answer. I feel it is less likely that a user has I have been doing some investigation. In my git bisecting I find that the git tag If you continue to feel strongly we can provide an option to support Footnotes
|
@HaoxuanGuo |
I'll try that out, hopefully in the next couple of days, and get back to you... though I believe you'd actually want
For my group's purposes, I am not wedded to the use of CMake, provided CFITSIO can be built out-of-tree by other means in a sufficiently-flexible manner (our cross-compilation setup's a little weird, and it took some effort to support it in the |
@simonrw Sorry for the late reply. I tested compile cfitsio on Windows, it successed but with a dependency hell. cftisio depends on pthreads and zlib; zlib depends on pwsh. Which means |
@HaoxuanGuo thanks for posting this information, but I'd like to split up integrating cmake and getting MSVC support working into two separate issues. I already have an open issue for MSVC support however it's not very well fleshed out! Would you mind adding your thoughts over there? Regarding cmake support @zec I think I am ok with including optional cmake support since it supports your use case. I don't think it should be default though, but I am unclear on the UX. Cargo features are meant to be additive, however we have two opposing features:
I am siding with 1. here, so can we do the following:
I am happy to help push this over the line but unfortunately I don't have much time to devote to this implementation myself, sorry. |
Regarding crate features: for optionally using the CMake build, I was thinking of having features with the following semantics:
This would be backward compatible while still having sensible meanings for any combination of features [1]. (Apologies for not getting around to testing building with the new version of CFITSIO yet; I've gotten pulled over to other things at work for the time being.) [1] |
I'm agree with @zec . Compatible is important for users and we should let it transparent. MSVC support is another tough work, only cmake discuss here, nor MSVC would deal with later in another issue. |
The current Autotools-based build process for the CFITSIO library in
fitsio-sys
(when enabled with thefitsio-src
feature) requires an in-tree build, i.e., the.o
files are placed in the same directory as the respective.c
files. This leads to build failures when usingfitsio
from crates.io when it is built for multiple platforms—at least not without the remediation of removing the.o
files,Makefile
, etc. from~/.cargo/registry/src
in between builds, which is a bad developer experience.This pull request switches from the Autotools-based build to using the alternative CMake-based build for CFITSIO. At the expense of requiring CMake to be installed, this allows for out-of-tree builds of CFITSIO, making multiple cross-compilations possible without needing a non-obvious remediation step.