Background
I'm trying out Scons by setting up a basic C++ sample project that has two sub-projects:
- Prj1 is an EXE that depends on Prj2
- Prj2 is a DLL that exports some functions
The problem I'm running into is that the library builds its .obj, .pdb, .lib, .dll, etc. files in the same directory as it's SConscript file while the EXE builds its files in the same directory as its SConscript. The application successfully builds both the Prj2 dependency and itself. However, you cannot run the resulting EXE because it can't find the library it needs because it is in the other directory.
Question
How can I get multiple projects that have dependences to output their binaries and debug information into a common directory so that they can be executed and debugged?
Potential Solutions
This is what I have thought of so far:
- I tried using VariantDir (previously called BuildDir) however this doesn't seem to work. Perhaps I'm messing something up here.
- I could potentially tell the compiler and the linker explicitly (via Fo/Fd for example) where to drop their files (is this the best or only solution???)
- Execute a copy command on the resulting binaries (this seems like a hack and quite a pain to manage/maintain)
Update
I updated the File Structure and file contents below to reflect the working solution in it's entirety. Thanks to grieve for his insight.
Command
With this configuration, you must unfortunately execute the build by cd'ing to the build directory and then running the command below. I need to get a properly working alias setup to get around this.
build> scons ../bin/project1.exe
File Structure
/scons-sample
/bin
/release
/debug
/build
SConstruct
scons_helper.py
/prj1
SConscript