Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在CMAKE中设置CMAKE_运行时_输出_目录后无法启动程序_C++_Cmake - Fatal编程技术网

C++ 在CMAKE中设置CMAKE_运行时_输出_目录后无法启动程序

C++ 在CMAKE中设置CMAKE_运行时_输出_目录后无法启动程序,c++,cmake,C++,Cmake,在我的CMakeLists.txt中,我设置set(CMAKE\u RUNTIME\u OUTPUT\u目录${CMAKE\u SOURCE\u DIR}/bin),以便将二进制文件设置到项目顶层的/bin目录 但是,现在当我按下“构建并运行”时,我得到以下错误: Unable to start program /long/path/to/build/release/ALL_BUILD path The system cannot find the file specified. 我认为这是

在我的
CMakeLists.txt
中,我设置
set(CMAKE\u RUNTIME\u OUTPUT\u目录${CMAKE\u SOURCE\u DIR}/bin)
,以便将二进制文件设置到项目顶层的
/bin
目录

但是,现在当我按下“构建并运行”时,我得到以下错误:

Unable to start program
/long/path/to/build/release/ALL_BUILD path

The system cannot find the file specified.

我认为这是因为二进制文件是在构建之后移动的。有没有办法更新Visual Studio对文件路径的了解?

ALL\u BUILD本身不是一个可运行的目标。它只是构建所有未明确排除在外的目标。您应该找到要运行的可执行文件的目标,然后通过右键单击菜单选择
设置为启动项目。

加载解决方案时,默认启动项目在解决方案浏览器窗格中以粗体显示。我认为VS只是在您第一次加载解决方案时选择第一个,这通常是CMake生成项目中的“所有构建”项目。