tags:

views:

29

answers:

0

My command wants to code a fast unit-test. We have lots of .cpp files that are tests of a library. The main idea is to generate precompiled header once, then build each .cpp file separately into .obj file. It must be done without a project having all these inside, since we want to know what particular .cpp failed, but all other compiled and tested.

Then we want to have a single .lib linked to .exe and then executed, so testing procedure will link one .obj after another and execute. The main problem is that we have 2 compilers VC2008 and VC2010. For each there is a Visual Studio Command Prompt, which configures environment for that particular compiler. By using cmd by hand, you need to something like, %comspec% /k ""C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86 to configure environment, and the just run cl.exe and link.exe.

Is there a way to do that from a C++ program? Open a cmd session, configure it and then run other commands with it?

We have that written in Python, but we are wondering - can it be done from C++, because we want to use some nice reporting tools we already have there? Thanks.