How to set the working directory for a Visual Studio 2017 RC CMake project

I use Visual Studio 2017 RC to open a CMake project, and then I find that the working directory is always the output directory.

Is there any way to set the working directory somewhere other than the output file directory?

(Since there is no .sln file, I cannot set the working directory as before)

Update I do not call programs from CMake scripts. I am running the target program in Visual Studio. And I want to change the working directory for the target program.

+4
source share
1 answer

(2017-03-23) CMakeLists.txt. :

launch.vs.json

( CMakeLists.txt). launch.vs.json, currentDir. :

{
  "version": "0.2.1",
  "defaults": {},
  "configurations": [
    {
      "type": "default",
      "project": "CMakeLists.txt",
      "projectTarget": "path\\to\\target",
      "name": "My Awesome Project",
      "currentDir": "${workspaceRoot}/src"
    }
  ]
}

, ; , , .vs/launch.vs.json.

CMake >= 3.8.0 VS_DEBUGGER_WORKING_DIRECTORY

. : CMake , / ?

VS_DEBUGGER_WORKING_DIRECTORY - CMake 3.8.0. :

set_target_properties(
    MyProject PROPERTIES
    VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")

CMake, .sln/.vcxproj, Visual Studio, CMake, Visual Studio 2017, 3,6. ...

, Visual Studio CMake >= 3.8.0

, ; CMake 3.7, . , , VS_DEBUGGER_WORKING_DIRECTORY.

+5

Source: https://habr.com/ru/post/1667829/


All Articles