cmake-rs icon indicating copy to clipboard operation
cmake-rs copied to clipboard

Add option to disable adding cmake c flags

Open chvck opened this issue 5 years ago • 6 comments
trafficstars

We are working with a project in which setting any cmake c flags causes cmake to end up with the incorrect set of flags. This adds an option to disable adding the c flags altogether.

chvck avatar Jul 14 '20 18:07 chvck

Thanks for the PR! I feel like though that one of the main purposes of this crate is to automatically add the appropriate C flags. With that disabled is there much gained over just simply calling cmake yourself?

alexcrichton avatar Jul 15 '20 14:07 alexcrichton

@alexcrichton well that is one way to do it. Our (couchbase) build.rs uses the cmake builder quite significantly (https://github.com/couchbaselabs/couchbase-rs/blob/master/couchbase-sys/build.rs#L9) we just found that on windows against visual studio we have to disable the cmake flags in order to get it to compile. (on linux and osx it works fine as in the source right now)

daschl avatar Jul 15 '20 18:07 daschl

Could you gist the error you were seeing with the cmake flags? Maybe there's a way to fix this in cc?

alexcrichton avatar Jul 16 '20 16:07 alexcrichton

Hello! It's interesting, but I've spotted a project (https://github.com/assimp/assimp) where adding -DCMAKE_CXX_FLAGS prevents it from compiling on Windows. I haven't investigated it yet, but in general - if this PR is going to be merged, is there any chance a similar option for cmake CXX flags can be added? Thanks!

UPD: In my case it looks like adding /EHs flag fixes the problem, but as to me, it is less clean than just to let package developers do what they wanted to do :)

curldivergence avatar Sep 19 '20 13:09 curldivergence

Hi! Is this still depending on something to be merged?

I have the same issue blocking my workflow https://github.com/esp-rs/esp-mbedtls/pull/15 which can be fixed by disabling the automatically generated cmake c flags.

AnthonyGrondin avatar Sep 20 '23 17:09 AnthonyGrondin

Hello, I'm also interested in this modification. I need to build paho-mqtt (which has a build dependency on cmake-rs) using a custom compiler arm-poky-linux-gnueabi (Yocto) for armv7-a, the presence of the CMAKE_C_COMPILER flag breaks the build, I need to remove it from the arguments to make it work.

I would be satisfied with something like this: https://github.com/rust-lang/cmake-rs/pull/185

lucasdietrich avatar Sep 22 '23 09:09 lucasdietrich