Tamás Varjas
09/13/2024, 10:49 AMcpp-library
plugin. (Note: I'm not talking about cross-compilation. I would like to compile for x86_64 on x86_64 and for arm64 on arm64).
I managed to solve the same using the old cpp
plugin like this (where arch
is determined based on a property passed in with -P
):
plugins {
id 'cpp'
}
model {
toolChains {
gcc(Gcc) {
target("linux_aarch64") {
cppCompiler.executable = '/usr/bin/gcc'
}
}
}
platforms {
x86_64 {
architecture 'x86_64'
}
linux_aarch64 {
architecture 'arm64'
operatingSystem 'linux'
}
}
components {
main(NativeLibrarySpec) {
targetPlatform arch
<...>
}
}
}
However, I've been unable to achieve the same using the cpp-library
plugin or even when "mixing" cpp
and cpp-library
, like below:
plugins {
id 'cpp'
id 'cpp-library'
}
model {
toolChains {
gcc(Gcc) {
target("linux_aarch64") {
cppCompiler.executable = '/usr/bin/gcc'
}
}
}
platforms {
x86_64 {
architecture 'x86_64'
}
linux_aarch64 {
architecture 'arm64'
operatingSystem 'linux'
}
}
}
library {
baseName = <...>
linkage = [Linkage.SHARED]
}
tasks.withType(CppCompile).configureEach {
targetPlatform arch
<...>
}
All attempts involving the cpp-library
plugin so far resulted in some variation of this error:
> Failed to notify project evaluation listener.
> No tool chain has support to build C++ for host operating system 'Linux' architecture 'aarch64':
- Tool chain 'gcc' (GNU GCC):
- Don't know how to build for host operating system 'Linux' architecture 'aarch64'.
Can you point me in the direction for how to solve this? Or should I just forget about cpp-library
as it is simply not doable?