CMake报错:add_subdirectory not given a binary directory but the given source directory

简介: 笔记

add_subdirectory命令,可以将指定的文件夹加到build任务列表中。

如果你的目录结构如下:

1.png

image.png

main是主工程的CMake目录,需要添加子目录模块sub1 ,那么语法如下:

默认情况下是添加当前目录的子目录,用法如下:

#只需要传入相对主目录的相对路径`sub1`
add_subdirectory(sub1)

如果还需要依赖外部目录(即不是主目录的子目录),就需要指定绝对路径,如下:

#CMAKE_CURRENT_SOURCE_DIR上当CMake目录
add_subdirectory(../3rdparty ${CMAKE_CURRENT_SOURCE_DIR})

不指定绝对路径就会报如下错误:

CMake Error at CMakeLists.txt:8 (add_subdirectory):
    add_subdirectory not given a binary directory but the given source
    directory "G:/NDKProject/OpenGLES/src/main/cpp/3rdparty/libpng" is not a
    subdirectory of "G:/NDKProject/OpenGLES/src/main/cpp/librenderer".  When
    specifying an out-of-tree source a binary directory must be explicitly
    specified.


目录
打赏
0
0
0
0
4
分享
相关文章
mkdir: cannot create directory `**': No such file or directory
在mkdir时报错的解决方案,在网上找了很多文章都没有说清楚原因。
545 0
CMake Error: The source “xxx“ does not match the source “yyy“ used to generate cache. Re-run cmake
CMake Error: The source “xxx“ does not match the source “yyy“ used to generate cache. Re-run cmake
1106 0
./configure *: No such file or directory
今天在CentOS下安装Nginx时,遇到了类似以下的问题: ./configure auto/unix: No such file or directory ./configure auto/options: No such file or directory 之前在另一台服务器上安装的时候也没有遇到此问题, 安装过程参考:CentOS6.5下Nginx1.7.4安装记录 于是网上搜索解决方案,但是搜索了很久也没有找到解决方案, 当我使用“mkdir auto/unix”之后,还是提示类似的错误,但目录名又变了。
3408 0
ERROR: file or directory not found: xx.py
​ 1、问题出现原因 在vscode中已导入pytest框架,做自动化demo小测试,运行Python文件一直出现如题错误,截图如下: ERROR: file or directory not found: xx.py  2、解决办法 1)直接把该文件移到当前主目录下,放在PYTHON-STUDY下 2)VSCode中右键tuopan.py文件,选择[在集成终端中打开],或者通过CD命令进入到tuopan.py文件所在目录 然后输入以下命令即可: 注:上述命令不是换行,在d:/前有空格 ,第一行信息为python所在安装路径,空格后的换行为运行的python文件的所在路径  
218 0
InvalidJobConfException: Output directory not set
InvalidJobConfException: Output directory not set
79 0
The file is in the program because: Imported via xxx Root file specified for compilation Vetur(1261)
The file is in the program because: Imported via xxx Root file specified for compilation Vetur(1261)
225 0
The file is in the program because: Imported via xxx Root file specified for compilation Vetur(1261)
Error running ‘ssm [clean]‘: No valid Maven installation found. Either set the home directory in the
Error running ‘ssm [clean]‘: No valid Maven installation found. Either set the home directory in the
156 0
完美解决common_define.h: No such file or directory
完美解决common_define.h: No such file or directory
277 0
完美解决common_define.h: No such file or directory
No valid Maven installation found. Either set the home directory in the configuration dialog or set
No valid Maven installation found. Either set the home directory in the configuration dialog or set
1191 0
No valid Maven installation found. Either set the home directory in the configuration dialog or set
gcc: error: /FIPython.h: File o directory non esistente
gcc: error: /FIPython.h: File o directory non esistente
151 0

热门文章

最新文章