I’m trying to make a plugin to include the headers and static libraries of the vulkan sdk. The examples in the gradle native samples repository showed me how to add the header files to the build programmatically. Now I’m trying to add a static library to add the vulkan static library to the build, and for the life of me I cannot figure it out.
The sample here shows code specific to groovy that I’m trying to translate to a kotlin plugin to add a library. What I’ve tried is this:
val sdkPath = System.getenv("VULKAN_SDK")
?: throw PluginNotSupportedException("This plugin requires that the vulkan sdk be installed on this machine.")
val vulkanHeaderPath = Paths.get(sdkPath).resolve("./Include/vulkan").normalize()
val vulkanLibPath = Paths.get(sdkPath).resolve("./Lib/vulkan-1.lib").normalize()
val application = project.properties["application"] as CppApplication
// this works
if (!application.privateHeaderDirs.contains(vulkanHeaderPath)) {
application.privateHeaders { from(vulkanHeaderPath) }
}
// this does NOT work
application.binaries.whenElementFinalized {
val binary = this
project.dependencies {
// the sample shows binary.linkLibraries.name which doesn't exist (?)
// not sure if it's a groovy only thing or something like that
add(binary.linkLibraries.singleFile.toString(), files(vulkanLibPath))
}
}
When I try this the error I get is:
Expected configuration ‘:nativeLinkDebug’ to contain exactly one file, however, it contains no files.
What is the correct programmatic way to link a static library to the executable?