CLion CMakeLists.txt 将 argv 参数添加到配置

CLion CMakeLists.txt add argv arguments to configuration

我在CMAkeLists.txt

中有配置
set(SOURCE_FILES client/client.cpp)
add_executable(Client ${SOURCE_FILES} client/client.cpp)

所以我可以在 CLion (Shift + F10) 中启动 client.cpp。但是,如果我需要使用 argv 参数启动 client.cpp(它有一个整数作为参数),我必须更改 CLion 中的配置,添加程序参数。

也许我可以使用 CMakeLists.txt 添加一些参数?

CMakeList 只负责配置你的程序,它通过生成一个 Makefile 来实现,然后它将构建你的程序二进制文件。 然后 Clion 使用您指定的参数启动二进制文件。