如何使用 Clion 调试外部可执行文件

How to debug outer executable using Clion

我想调试 Clion 使用外部 makefile 创建的可执行文件。
我看到我可以在 Run/Debug Configurations --> Executable 中选择另一个可执行文件,但它会自动运行我不想运行的 CMakeLists(因为它失败)。

我知道 Clion 目前不支持 "import project with existing makefile"。

有办法吗?

  1. 使用 Cmakeadd_custom_command()add_custom_target() 我调用了我的 makefile
  2. Clion Run/Debug Configuration --> Executable 中,我从我的 makefile 中选择了已编译的可执行文件。

--- 编辑 ---
1.例子

add_custom_command(OUTPUT app_run.txt
    COMMAND /bin/echo "Not building!"
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_custom_target(app_run ALL
    DEPENDS app_run.txt)