Islam Hassan
Islam Hassan

Reputation: 1736

How to build a C++ project into the same folder as the source file's in KDevelop

Suppose I'm writing a code to read from a file and printing its content, and I'm modifying its content so often that I need it to be visible from the projects tool view. The problem is that KDevelop forces me to build the code in a separate folder (i.e. build folder). So the project structure goes like this.

--> Project Folder
 |
 --> code.cpp
 --> file.txt
 --> build 
  |
  --> code (exe file)

Now building and executing the project won't work as expected, because file.txt is not beside the executable file, so it can't read its content.

Moving file.txt into build folder won't work as it will exclude it from the projects tool view in KDevelop (i.e. I can't access the file from the left pane in KDevelop).

Creating a shortcut of file.txt and moving it into build folder so the file is besides the source code, and its shortcut is in build folder will do it, but for every time I want to rename the file, I need to create a new shortcut or rename the one in build folder.

What should I do? I think it can be handled by one of two ways.

Are there any suggestions? I've tried QtCreator and it allows me to do both.

Upvotes: 0

Views: 790

Answers (1)

sebasgo
sebasgo

Reputation: 3851

The usual way to handle this case is to use an additional install step after building. In this step the final binaries from the build directory and additional files from the source directory are copied to a third location.

How this is achieved depends on the build system you employ.

Upvotes: 1

Related Questions