在我的项目中,我使用的是cpp和.h文件,它们都在不同的文件夹中
this.dataStorage.recipeSubscription.subscribe((res) => {
// Do stuff.
});
this.dataStorage.getRecipes();
在当前版本中,我将每个文件添加到|-src
|-main
|-java
|-cpp
|-native-lib.cpp
|-library-1
|-include
|-lib11.h
|-lib12.h
|-...
|-library-2
|-include
|-lib21.h
|-lib22.h
|-...
'CMakeLists.txt'
我尝试添加如下
...
add_library(# Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp
src/main/cpp/library-1/include/lib10.h
src/main/cpp/library-1/include/lib11.h
src/main/cpp/library-1/include/lib12.h
src/main/cpp/library-1/include/lib13.h
...
src/main/cpp/library-2/include/lib21.h
src/main/cpp/library-2/include/lib22.h
src/main/cpp/library-2/include/lib23.h
...
)
...
使用...
add_library(# Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp
src/main/cpp/library-1/include/*.h #expected result: it will include all '.h' files in directory, but gradle sync failed
src/main/cpp/library-2/include/*.h#expected result: it will include all '.h' files in directory, but gradle sync failed
)
...
来自Lucky的建议
add_library
答案 0 :(得分:9)
您可以生成源文件列表:
file(GLOB SOURCES "src/*.h")
现在,SOURCES变量可以用作add_library中的参数。
add_library(native-lib SHARED ${SOURCES})