rust-qt / ritual

Use C++ libraries from Rust
Apache License 2.0
1.24k stars 49 forks source link

Use gcc crate instead of cmake? #2

Open emoon opened 8 years ago

emoon commented 8 years ago

Right now cmake is required for building the lib generated by cpp_to_rust an alternative would be to use the gcc crate instead which would remove the need for the user to have cmake installed.

Riateche commented 8 years ago

I think it would be nice to remove dependency on cmake, but I don't want to reinvent cmake. It actually solves a lot of issues:

All this is accomplished with a very simple config file (less than 20 lines). How much code will it take to implement the same behavior using gcc crate? How much of these features can it provide?

emoon commented 8 years ago

In the simplest form using the gcc crate is this

// build.rs

extern crate gcc;

fn main() {
    gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]);
}
Riateche commented 8 years ago

But MSVC libraries are .lib, not .a. Also it seems that this crate doesn't support shared libraries, only static ones. I need shared libraries for MSVC because it can't compile them statically (too many symbols).

emoon commented 8 years ago

The gcc crate uses *.a even for msvc. I have used this in several projects and it works just fine. I have never ran into the issue with too many symbols on msvc so unsure about that.

Riateche commented 8 years ago

Actually, this feature would be useful even if it doesn't cover all use cases. We can leave cmake as default option and fallback to gcc crate if cmake is not available and there are no other issues.

emoon commented 8 years ago

Sounds good!