0

Gradle 提供了一个可以编译 cpp-library 的插件

构建.gradle.kts

plugins {
    `cpp-library`
}
library {
    targetMachines.add(machines.windows.x86_64)
    linkage.set(listOf(Linkage.SHARED))
    source.from("src/main/cpp/*.txt")
}

我的输出低于

:compileDebugCpp NO-SOURCE

如何使用source.from指定自定义文件扩展名,如*.txt

4

1 回答 1

0

我自己找到了解决方案

我需要将源代码放在编译任务中,如下所示

tasks.withType(CppCompile::class.java).configureEach {
    source.from(fileTree("${project.rootDir}/${project.name}/src/main/cpp").matching {
        include("*.txt")
    })
}

这允许 gradle C++ 编译器任务编译.txt文件而不是.cpp文件

因此,如果我想编译,fortran那么我可以放置*.f*.f90

于 2021-07-22T11:47:17.283 回答