When we run a C++ program with Visual Studio, we often set "Command Arguments" insider Configuration Properties->Debugging if the program need some arguments. For example, we may run abc.exe -r 1 in the command line, and in order to run the program directly in Visual Studio, we can fill the Command Arguments with -r 1 . So my question is: can we set default Command Arguments with cmake? By doing so, there is no need to set them manually. Thanks.
-
1possible duplicate of How to Set Path Environment Variable using CMake and Visual Studio to Run Teststijn– stijn2014-08-05 09:12:13 +00:00Commented Aug 5, 2014 at 9:12
-
I believe you can do this by using cmake commands to generate a .user file.drescherjm– drescherjm2014-08-06 08:53:05 +00:00Commented Aug 6, 2014 at 8:53
-
Possible duplicate of CMake: Adding command line arugments to projectBeginner– Beginner2017-04-19 13:38:15 +00:00Commented Apr 19, 2017 at 13:38
Add a comment
|
1 Answer
You could add this into your CMakeLists.txt:
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/abc.vcxproj.user"
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<Project ToolsVersion=\"15.0\">\n"
" <PropertyGroup>\n"
" <LocalDebuggerCommandArguments>-r 1</LocalDebuggerCommandArguments>\n"
" <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>\n"
" </PropertyGroup>\n"
"</Project>")
You might want to adapt this to your version of Visual Studio.