在〜/ work / src / unittest / CMakeLists.txt中,我使用include命令
include (${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)
在〜/ work / src / CMakeLists.txt中,
file (STRINGS "../profile" profile)
我想在unittest路径中使用cmake。
错误消息:
CMake Error at ~/work/src/CMakeLists.txt:13 (file):
file STRINGS file
"~/work/src/unittest/../profile" cannot be
read.
Call Stack (most recent call first):
CMakeLists.txt:6 (include)
我能怎么做?
答案 0 :(得分:0)
当include()
CMake-script时,您不会更改当前的源目录(和二进制文件)。但通常CMakeLists.txt
期望源目录反映CMakeLists.txt
本身的位置。
使用include()
:
CMakeLists.txt
add_subdirectory
add_subdirectory(
"${CMAKE_CURRENT_SOURCE_DIR}/../" # Source directory, contains CMakeLists.txt file
"myproject" # Build directory, will be created and used for output files
)