在 CMAKE 中包含来自 Android 项目不同文件夹的静态库
Including a static library in CMAKE from a different folder for an Android Project
我正在尝试将我的Android NDK cpp项目(ndk-build with Android.mk)转换为Android Studio中的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
模块 1 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 )
MyProject CMakeLists.txt:
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 中?
建议修复自:
使用 CMake 添加不在子目录中的依赖项
为我工作。
include_directories(../MyMModule1/include/)
add_subdirectory("../MyMModule1/" "${CMAKE_CURRENT_BINARY_DIR}/MyModule1_build")
相关文章:
- 如何将更多文件夹添加到c++include路径
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 如何在文档文件夹中创建目录
- "assimp/config.h"找不到,但它在文件夹中
- C++入门 5 版:类消息和文件夹
- 我可以在 Arduino 的库文件夹之外安装库吗?
- 如何按文件扩展名引用文件夹中的文件
- 在QTreeView中仅显示共享驱动器和文件夹
- 加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
- 介子复制/安装头文件到输出目录并保持文件夹结构
- vcruntime.h 从 Windows 包含文件夹中丢失?
- 在文件夹迭代上实现 RAII
- 给定一个C++嵌套的私有结构类型,是否有从文件范围静态函数访问它的策略
- 使用 Powershell 命令将 cpp 文件的文件夹编译为 GNU 的 g++
- 使文件夹中的所有文件可供所有项目(子目录)访问
- 复制文件流C++静态变量
- 在 CMAKE 中包含来自 Android 项目不同文件夹的静态库
- 如何在“选择文件夹”对话框中为静态控件的背景着色