The default Visual Studio debugger working directory is $(ProjectDir)
.
I really want it to be installed in $(TargetDir)
(where is .exe
it that I run).
This answer contains 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, these are hard codes Debug
that I don't like.
I tried $<CONFIG>
at the end, but this was not valid in Visual Studio (expression is not evaluated).
I also tried $(TargetDir)
, but this does not work. But if I manually delete the variable $(TargetDir)
and paste it back in, it will work.
How to set the debugger working directory to an executable output directory without hard coding?
source
share