Closed stanhu closed 1 year ago
This looks great! Thank you!
Great addition! Thank you!
@stanhu I'm curious why we're not using RbConfig::CONFIG["CC"]
and ["CXX"]
here ... would that simplify things?
Asking because OpenBSD and FreeBSD support have been ... interesting.
I'm curious why we're not using RbConfig::CONFIG["CC"] and ["CXX"] here ... would that simplify things?
@flavorjones Yeah, that could would work. It looks like mini_portile2
uses RbConfig::CONFIG['CC']
here, so maybe we can simplify this further by using gcc_cmd
and introducing something like gxx_cmd
: https://github.com/flavorjones/mini_portile/blob/af3f9d2a8359f31bcfa64e40492357f7d07bce30/lib/mini_portile2/mini_portile.rb#L376
I think I might have been focused on ENV["CC"]
because that's what configure
uses. I think I defaulted to clang
for macOS because the cross-compile images for macOS has compilers with clang-#{host}
(e.g. clang-arm64-apple-darwin22
). But I think the cross-compile images should have reasonable values for RbConfig::CONFIG["CC"]
that match with the image, so that approach should work.
I've opened a PR to simplify compiler detection at https://github.com/flavorjones/mini_portile/pull/144
For the standard
make
, mini_portile provides theconfigure
script with the--host
parameter, and the script figures out the target compilers to use. With CMake, we don't have that benefit so we need to set the C and C++ compilers ourselves.This commit uses a simple heuristic to find the target compilers:
clang
andclang++
. Otherwise usegcc
andgcc++
.<host>-compiler
. Use that if we find it. Otherwise default to the base compilers.To make CMake work with cross-compilation, a number of variables have to be set:
Closes #128