Gradle - Compiling Using the C ++ Submodule Library

I am trying to set up a project in C ++, which itself uses another C ++ project (not gradle).

Since compilation does not require anything special, I tried to include the project as a submodule and compiled this library as a library via gradle.

As far as I know, I created the script construct correctly as follows:

// 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" } } } } } 

Although, 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 someone help me with what I am doing wrong? (The repo can be found here , and the time version of posting this question is: e518d77c4d )

+5
source share

Source: https://habr.com/ru/post/1274129/


All Articles