Skip to content
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

Map CMake compilers to cargo build environment variables #85

Closed
Chaz6 opened this issue Jan 25, 2021 · 5 comments · Fixed by #138
Closed

Map CMake compilers to cargo build environment variables #85

Chaz6 opened this issue Jan 25, 2021 · 5 comments · Fixed by #138

Comments

@Chaz6
Copy link

Chaz6 commented Jan 25, 2021

I tried to compile a project that failed because it used c++ instead of the compiler specified in CMAKE_CXX_COMPILER (for example, clang++). I temporarly fixed this by making a link to clang++ from c++ in a location searched by $PATH before /usr/bin, but I think the better solution would be for corrosion to use the compiler specified by CMAKE_CXX_COMPILER.

@AndrewGaspar
Copy link
Collaborator

Was this in the context of a build script in Cargo? This is something I've wanted to fix at some point - basically, when invoking cargo, set CC, CXX, etc. to the compilers selected by CMake.

@Chaz6
Copy link
Author

Chaz6 commented Jan 27, 2021

The project I was trying to build is https://invent.kde.org/graphics/pikasso/ and I am afraid I am not a rust expert, but I enjoy experimenting with new things! I could not find a Cargo.toml but the CMakeLists.txt contains this:-

find_package(Corrosion)
set_package_properties(Corrosion PROPERTIES
    PURPOSE "Required for transforming the paths to vertices and indices"
    DESCRIPTION "CMake scripts to seamlessly build and link to targets using cargo"
    URL https://github.com/AndrewGaspar/corrosion
)

Edit: I did not look very hard. There is a Cargo.toml and it contains the following:-

[package]
name = "tessellation-ffi"
version = "0.1.0"
authors = ["Carl Schwan <carlschwan@kde.org>"]
edition = "2018"

[lib]
crate-type = ["staticlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
cxx-build = "1.0.28"

[dependencies]
lyon = {version = "0.17.0" }
cxx = "1.0"

@AndrewGaspar
Copy link
Collaborator

Yeah, looks like the case then - this is a known issue. Thank you for filing this!

As a work around, you should also be able to set CXX=clang++ and get the same behavior, I think.

@AndrewGaspar AndrewGaspar changed the title CMAKE_CXX_COMPILER is ignored Map CMake compilers to cargo build environment variables Jan 27, 2021
@surprized
Copy link

Not sure what is going wrong here, but I packaged PIkasso without modiying anything, except I exported some rustc flags.
The current gcc bundled in Tumbleweed is gcc-10 IIRC.

@AndrewGaspar
Copy link
Collaborator

This issue only comes up if you're trying to use a compiler that is not your "default" system compiler (i.e. mapped to cc/c++, or set via the CC/CXX environment variables). What's happening is that CMake and the Cargo cc crate disagree on which C++ compiler to use because @Chaz6 explicitly set the C++ compiler to use via CMAKE_CXX_COMPILER.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants