Does CMake offer a method to set the working directory for a given build system to use when running/debugging the project?

Peter Clark

I have a project with the following structure:

project_name/CMakeLists.txt
project_name/src
project_name/resources
...
project_name-build/configuration_name/project_name.exe

I want my application to be run in the root project directory project_name so it can directly access resources.

Does CMake provide a method to specify this property, or will I have to manually set it in each build environment I use?

I've looked around in the documentation and haven't found anything other than the possibility of setting up a post-build event to run my project from the desired directory which is less than desirable. I also found that the working directory setting for Visual Studio is saved in a per-user file (.vcxproj.user) which I don't believe CMake generates (which points to the answer being probably no).

tambre

Since CMake 3.8, there is the VS_DEBUGGER_WORKING_DIRECTORY target property, which allows you to set the debugger working directory for a target in Visual Studio.

Usage example:

set_property(TARGET MyTarget PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Set project dependent build system variables

From Java

CMake output/build directory

From Dev

How does Unix keep track of a user's working directory when navigating the file system?

From Dev

How does Unix keep track of a user's working directory when navigating the file system?

From Dev

Build Project Tree in CMake

From Dev

Build Project Tree in CMake

From Dev

Use Frama-c to analyze a project with CMake build infrastructure

From Dev

Cmake: don't build project again when executing make install

From Dev

Why does Files.isWritable() method return true for a directory even when it is set to read only?

From Dev

A build system with CMAKE or not for system composition

From Dev

Why does VS.NET 2013 create a dll file in the bin directory when I build my HTML5 Typescript project?

From Dev

Set an .Rmd in a package to write files to the current project working directory

From Dev

Qt w/ Cmake: set(QT_USE_QTWEBKIT TRUE) not working

From Dev

CMake: wrong build target directory

From Dev

How to use CMake to build multiple platforms from one master CMake project without cache problems

From Dev

Use Tesseract in CMAKE project

From Dev

SDL project CMake build failure

From Dev

Group build targets in CMake project

From Dev

SDL project CMake build failure

From Dev

Group build targets in CMake project

From Dev

How to use external build system for Visual C++ 2013 project?

From Dev

How does `go build` decide which subdirectories to build when it is not given specific packages to build?

From Dev

Multi-Project cmake not working

From Dev

Set Working Directory to Notebook Directory

From Java

Emacs Interactive-Haskell repl non-response if either the cabal or working directory set to project directory

From Dev

Set vim current working directory to the current project root or to the directory of the current file

From Dev

Set vim current working directory to the current project root or to the directory of the current file

From Dev

Set the number of threads in a CMake build

From Dev

CMake: set folders for build products

Related Related

  1. 1

    Set project dependent build system variables

  2. 2

    CMake output/build directory

  3. 3

    How does Unix keep track of a user's working directory when navigating the file system?

  4. 4

    How does Unix keep track of a user's working directory when navigating the file system?

  5. 5

    Build Project Tree in CMake

  6. 6

    Build Project Tree in CMake

  7. 7

    Use Frama-c to analyze a project with CMake build infrastructure

  8. 8

    Cmake: don't build project again when executing make install

  9. 9

    Why does Files.isWritable() method return true for a directory even when it is set to read only?

  10. 10

    A build system with CMAKE or not for system composition

  11. 11

    Why does VS.NET 2013 create a dll file in the bin directory when I build my HTML5 Typescript project?

  12. 12

    Set an .Rmd in a package to write files to the current project working directory

  13. 13

    Qt w/ Cmake: set(QT_USE_QTWEBKIT TRUE) not working

  14. 14

    CMake: wrong build target directory

  15. 15

    How to use CMake to build multiple platforms from one master CMake project without cache problems

  16. 16

    Use Tesseract in CMAKE project

  17. 17

    SDL project CMake build failure

  18. 18

    Group build targets in CMake project

  19. 19

    SDL project CMake build failure

  20. 20

    Group build targets in CMake project

  21. 21

    How to use external build system for Visual C++ 2013 project?

  22. 22

    How does `go build` decide which subdirectories to build when it is not given specific packages to build?

  23. 23

    Multi-Project cmake not working

  24. 24

    Set Working Directory to Notebook Directory

  25. 25

    Emacs Interactive-Haskell repl non-response if either the cabal or working directory set to project directory

  26. 26

    Set vim current working directory to the current project root or to the directory of the current file

  27. 27

    Set vim current working directory to the current project root or to the directory of the current file

  28. 28

    Set the number of threads in a CMake build

  29. 29

    CMake: set folders for build products

HotTag

Archive