CLion CMakeLists.txt add argv arguments to configu

2019-07-12 18:25发布

问题:

I have configuration in CMAkeLists.txt

set(SOURCE_FILES client/client.cpp)
add_executable(Client ${SOURCE_FILES} client/client.cpp)

So I can launch client.cpp in CLion (Shift + F10). But if I need to launch client.cpp with argv parameter (it has one integer as parameter) I must change configuration in CLion adding program arguments.

Maybe I can add some parameters using CMakeLists.txt?

回答1:

CMakeList is only responsible for configuring your program, it does so by generating a Makefile, which then will build your program binary. Clion then launch the binary using the arguments you specified.