How can I set an intermediate build directory?

Added by Ben Hymers almost 11 years ago

This question likely has a blindingly obvious answer, but I can't for the life of me figure it out.

How can I set an 'intermediate' directory for my build; a directory where object files and so on get placed? I'd like Jam files (including dependency cache) in something like scripts/jam/ (done), built files in something like bin/ or lib/ (done), and object files etc. in something like build/ (not done - currently they all get put in scripts/jam/, which I find a bit messy!).

It's not exactly a huge problem, especially since Jam is so good with dependencies. I mostly just want it to mirror the way I had things set up in Visual Studio, where if I wanted a proper clean I could just delete bin/ lib/ and build/, since sometimes it didn't quite work right otherwise!

Replies (2)

RE: How can I set an intermediate build directory? - Added by Marc Dubreuil almost 11 years ago

I find the best tutorials are located in the "tests" folder. To answer your question, look at the "tests" : source_and_jamfiles_separate and manifest_generation (look for the Jamfile.jam in source/project1)

source_and_jamfiles_separate will show you how to put jamfiles and source code in two different directories.

manifest_generation will show you how to put output in another directory.

In short, what you want to do is this:

Change the LOCATE_TARGET variable to where you want your output binaries (.obj)

This will be converted to Output/Temp/NAME_OF_YOUR_LIBRARY/win32/debug if you are building debug.

Then, you may want to change where your executable and dll will be found after the build with the rule OutputPath. It may not be at the same place as your object files, and it becomes clearer that way anyway

This will be converted to Output/win32/debug/NAME_OF_YOUR_EXECUTABLE

Of course, you can always create a rule that you will then call for each of your libraries/executables. That rule can go in the file Jamrules.jam.

Hope that help.

RE: How can I set an intermediate build directory? - Added by Joshua Jensen almost 11 years ago

Intermediates are controlled via LOCATE_TARGET, assigned per SubDir call, or ALL_LOCATE_TARGET which affects the location of all intermediates. The final outputs will go to the LOCATE_TARGET directories, too, if OutputPath is not called.

Alternatively, the JamPlus is set up for a completely out of source build. You can use bin/scripts/JamToWorkspace.bat to generate an out of source build location for you. You'll still need to call OutputPath appropriately, though.

Thanks, Marc, for your detailed response.