Hi. I’m trying to setup a C++ project that itself uses another (not gradle) C++ project.
Since the compilation doesn’t require anything special I tried including the project as a submodule and compiling that library as a library through gradle itself.
To my knowledge I have set up the build script correctly like this:
// Project-Type
apply plugin: "cpp"
// IDEs
apply plugin: "visual-studio"
model {
visualStudio {
solutions.all {
solutionFile.location = "vs/${name}.sln"
solutionFile.withContent { TextProvider content ->
content.asBuilder().insert(0, "# GENERATED FILE: DO NOT EDIT\n")
content.text = content.text.replaceAll("HideSolutionNode = FALSE", "HideSolutionNode = TRUE")
}
}
}
repositories {
libs(PrebuiltLibraries) {
easyloggingpp {
headers.srcDir "lib/easyloggingpp/src"
}
eigen {
headers.srcDir "lib/OpenNN/eigen/src"
}
}
}
platforms {
x86 {
architecture "x86"
}
x64 {
architecture "x64"
}
}
buildTypes {
debug
release
}
components {
tinyxml2(NativeLibrarySpec) {
sources.cpp {
source {
srcDirs "lib/OpenNN"
include "tinyxml2/**/*.cpp"
}
exportedHeaders {
srcDirs "lib/OpenNN"
include "tinyxml2/**/*.h"
}
}
}
openNN(NativeLibrarySpec) {
sources.cpp {
source {
srcDirs "lib/OpenNN"
include "opennn/**/*.cpp"
}
exportedHeaders {
srcDirs "lib/OpenNN"
include "opennn/**/*.h"
}
lib library: "eigen", linkage: "api"
lib library: "tinyxml2", linkage: "static"
}
}
anni(NativeExecutableSpec) {
if(System.properties['sun.arch.data.model'] == "64") {
targetPlatform "x64"
} else {
targetPlatform "x86"
}
sources.cpp {
source {
srcDirs "src"
include "**/*.cpp"
}
exportedHeaders {
srcDirs "src"
include "**/*.hpp"
}
lib library: "easyloggingpp", linkage: "api"
lib library: "openNN", linkage: "static"
}
}
}
binaries {
withType(NativeExecutableBinarySpec) {
if (toolChain in Gcc) {
cppCompiler.args "-Wall", "-Wextra", "-Wpedantic", "-fPIC"
}
if (toolChain in Clang) {
cppCompiler.args "-Weverything", "-pedantic"
}
if (toolChain in VisualCpp) {
cppCompiler.args "/W4", "/FS", "/EHsc"
}
}
withType(SharedLibraryBinary) {
buildable = false
}
withType(StaticLibraryBinarySpec) {
if (toolChain in Gcc) {
cppCompiler.args "-Werror"
}
if (toolChain in Clang) {
cppCompiler.args "-Werror"
}
if (toolChain in VisualCpp) {
cppCompiler.args "/W0", "/EHsc"
}
}
all {
if(buildType == buildTypes.debug) {
cppCompiler.define "__DEBUG__"
if (toolChain in Gcc) {
cppCompiler.args "-Og", "-g3"
}
if (toolChain in Clang) {
cppCompiler.args "-O0", "-g"
}
if (toolChain in VisualCpp) {
cppCompiler.args "/Od", "/Z7"
}
}
if(buildType == buildTypes.release) {
cppCompiler.define "__NDEBUG__"
if (toolChain in Gcc) {
cppCompiler.args "-Ofast", "-g0"
}
if (toolChain in Clang) {
cppCompiler.args "-Ofast", "-g0"
}
if (toolChain in VisualCpp) {
cppCompiler.args "/O2"
}
}
}
}
}
Though when I run gradle build
I get the following error:
Parallel execution is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':linkAnniReleaseExecutable'.
> No static library binary available for library 'openNN' with [flavor: 'default', platform: 'x64', buildType: 'release']
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Can anyone help me with what I’m doing wrong?
(The repo can be found here and the version of the time of posting this question is: e518d77c4d)