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.


目录
相关文章
|
10月前
mkdir: cannot create directory `**': No such file or directory
在mkdir时报错的解决方案,在网上找了很多文章都没有说清楚原因。
199 0
|
11月前
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
438 0
|
4天前
|
Shell
adb: error: cannot create file/directory ‘d:/1.png‘: No such file or directory
adb: error: cannot create file/directory ‘d:/1.png‘: No such file or directory
10 0
|
6月前
|
Python
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文件的所在路径  
73 0
|
8月前
cancal报错 config dir not found
cancal报错 config dir not found
|
12月前
|
Java Maven
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
|
JavaScript
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)
125 0
The file is in the program because: Imported via xxx Root file specified for compilation Vetur(1261)
完美解决common_define.h: No such file or directory
完美解决common_define.h: No such file or directory
133 0
完美解决common_define.h: No such file or directory
|
C语言 Python Windows
gcc: error: /FIPython.h: File o directory non esistente
gcc: error: /FIPython.h: File o directory non esistente
90 0
|
C语言
gcc is unable to create an executable file.
gcc is unable to create an executable file.
223 0