I have a C++ project and trying to link against a library built in another project that compiles a C library with gcc.
If I build the first project “A” and use the following in “B” which uses cpp plugin I can compile and run fine. However, I fail from a clean build with parallelization, because the prebuilt library isn’t there yet.
What I would like is a mechanism that I can force A’s build to run to completion before reaching B’s linkTestExecutable that tries to link my “prebuilt” library. My issue, is the use of some C includes won’t let me compile A with the g++ compiler.
What are my options?
apply plugin: 'cpp'
build.dependsOn([':A:build'])
clean.dependsOn([':A:clean'])
model {
components {
B (NativeExecutableSpec) {
sources {
cpp {
lib library: "myA", linkage: 'static'
}
}
}
}
}
model {
repositories {
libs(PrebuiltLibraries) {
myA {
def baseDir = "../A/build/libs/A/static/"
headers.srcDir "../A/src/A/headers/"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("${baseDir}/libA.a")
}
}
}
}
binaries {
all {
cppCompiler.args "-std=c++11", "-pthread","-fPIC","-ggdb", "-fext-numeric-literals"
}
}