13

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.

3

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.