Visual Studio's debugger's default working directory is $(ProjectDir).
What I really want is it to be set to $(TargetDir) (where the .exe I am running is located).
This answer provides the correct syntax, so I tried the following:
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${PROJECT_BUILD_DIR}/Debug)
endif()
However this hard-codes Debug, which I don't like.
I tried $<CONFIG> at the end but that was invalid in Visual Studio (the expression is not evaluated).
I also tried $(TargetDir), but that doesn't work. But if I manually delete the variable $(TargetDir) and paste it back in, it works.
How can I set the debugger working directory to the executable output directory without hard-coding it?