Closed stanhu closed 1 year ago
In order to build a C extension against a library, we may also want to add:
Ack. CMake is still "experimental" and you may be the first person to really try to use it for something. Will take a look, but prioritizing it behind some other work at the moment.
While working on https://github.com/mudge/re2/pull/67, I had to add a number of configuration options to make cross-compiling work properly.
For the standard
make
, mini_portile2 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.I used 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:
I was surprised that
CMAKE_SYSTEM_NAME
has to be set, orcmake
won't try to cross-compile.I think
mini_portile2
should provide these options by default.