Author Topic: Current Directory  (Read 4396 times)

Offline johne53

  • Regular
  • ***
  • Posts: 253
Current Directory
« on: August 10, 2007, 12:06:56 pm »
Let's suppose I have a C::B project with several sub-projects (i.e. dependencies). The dependencies are all in their own particular folders. I suppose that the ".cbp" files could either be in one folder - or maybe each ".cbp" file could be in the root folder for that dependency. I don't suppose it matters.

Either way - is it possible that when I compiile each of the dependencies, I can set up C::B to select that particular root folder as being the current directory? e.g. if I compile project "abc", /my/root_folder/abc/ would become the current directory - but when I compile project "def", /my/root_folder/def/ will become the current directory.

I'd be surrpised if this isn't possible - but I can't find anywhere to do it.

mariocup

  • Guest
Re: Current Directory
« Reply #1 on: August 10, 2007, 12:46:05 pm »
Hi johne53,

codeblocks support dependices for projects. You must save the projects in a workspace and define the dependencies for the built process. The dependencies are not saved in the project description (*.cbp) but in the workspace. See http://codeblocks.org/manual.shtml for details.

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: Current Directory
« Reply #2 on: August 10, 2007, 08:17:52 pm »
Thanks Mariocup. I think we might be at crossed purposes here....

In this project (which I've inherited) the header files are arranged quite unusually. For example, in the "abc" branch, the source files might be in /my/root_folder/abc/ and the corresponding headers (for some strange reason) are in /my/root_folder/abc/abc/. Similarly, the source files for the "def" branch would be in /my/root_folder/def/ and their header files would be in /my/root_folder/def/def/. Any given source file might have a #include such as #include "/abc/SomeHeader.h" - or in the def branch, it would be #include "def/SomeHeader.h".

At the moment, I'm having to put all these (dozens) of include folders into my folder search paths. Either that - or I have to modify all the #includes to include a full, absolute path.

It's obvious that this project was designed for a build environment that switches the current working directory as it builds each branch. So let's say that I'm compiling the "abc" branch. If C::B could simply select /my/root_folder/abc/ as the current working directory, the project would compile without modification. Then if I compile the "def" branch, it should select /my/root_folder/def/ as the current working directory - etc, etc.

AFAIK, most compilers do this automatically. It's quite common for the current project folder to become the current working directory, at the start of each build. I'm a bit surprised that C::B doesn't seem to be doing this but I feel sure that it must be possible.

Hope that's a bit clearer.

mariocup

  • Guest
Re: Current Directory
« Reply #3 on: August 10, 2007, 10:32:30 pm »
Hi johne53,

perhaps you can try something different. CB has very powerful variable expansion. So you might have project "abc" for the branch abc and a project "def" for the branch def.

Now define a custom variable in the project built options for each project e.g. BRANCH and set it to abc or def. Then add to the search dirs the folder ./$(BRANCH).

Now we can simply write "#include SomeHeader.h".

Could this be a solution?