在CMAKE中包含一个用于Android项目的不同文件夹中的静态库

在CMAKE中包含一个用于Android项目的不同文件夹中的静态库,android,c++,android-studio,cmake,static-libraries,Android,C++,Android Studio,Cmake,Static Libraries,我正试图在Android Studio中将我的Android NDK cpp项目(NDK build with Android.mk)转换为CMAKE。我有这样一个项目层次结构: . ├── Module1 │   ├── CMakeLists.txt │   ├── include │   │   └── Module1 │   ├── libModule1 │   │   ├── Module1File1.cpp │   │   └── Module1File2.cpp │   └── ut

我正试图在Android Studio中将我的Android NDK cpp项目(NDK build with Android.mk)转换为CMAKE。我有这样一个项目层次结构:

.
├── Module1
│   ├── CMakeLists.txt
│   ├── include
│   │   └── Module1
│   ├── libModule1
│   │   ├── Module1File1.cpp
│   │   └── Module1File2.cpp
│   └── utModule1
├── MyProject
│   ├── CMakeLists.txt
│   ├── MyProject.iml
│   ├── build
│   │   ├── generated
│   │   ├── intermediates
│   │   └── outputs
│   ├── build.gradle
│   ├── proguard-rules.pro
│   └── src
│       │
│       ├── MyProjectFile1.cpp
│       └── MyProjectFile2.cpp
|
└── settings.gradle
Module1 CMakeLists.txt:

cmake_minimum_required(VERSION 3.4.1)
add_library( # Specifies the name of the library.
             Module1

             # Sets the library as a shared library.
             STATIC

             # Provides a relative path to your source file(s).
             libModule1/Module1File1.cpp
             libModule1/Module1File2.cpp )
cmake_minimum_required(VERSION 3.4.1)

add_subdirectory(../MyModule1)

add_library( # Specifies the name of the library.
             MyProject
             # Sets the library as a shared library.
             SHARED
             # Provides a relative path to your source file(s).
             src/MyProjectFile1.cpp
             src/MyProjectFile2.cpp)

target_link_libraries( # Specifies the target library.
        MyProject
        # Dependencies
        MyModule1
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})
MyProject-CMakeLists.txt:

cmake_minimum_required(VERSION 3.4.1)
add_library( # Specifies the name of the library.
             Module1

             # Sets the library as a shared library.
             STATIC

             # Provides a relative path to your source file(s).
             libModule1/Module1File1.cpp
             libModule1/Module1File2.cpp )
cmake_minimum_required(VERSION 3.4.1)

add_subdirectory(../MyModule1)

add_library( # Specifies the name of the library.
             MyProject
             # Sets the library as a shared library.
             SHARED
             # Provides a relative path to your source file(s).
             src/MyProjectFile1.cpp
             src/MyProjectFile2.cpp)

target_link_libraries( # Specifies the target library.
        MyProject
        # Dependencies
        MyModule1
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})
我在生成时看到以下错误:

CMake Error at CMakeLists.txt (add_subdirectory):
如何将MyModule1包含到MyProject中?

建议的修复程序来自:

为我工作

include_directories(../MyMModule1/include/)
add_subdirectory("../MyMModule1/" "${CMAKE_CURRENT_BINARY_DIR}/MyModule1_build")

您忘记将错误消息的其余部分包含在问题帖子中。