I am using VS2008, and developing C/C++ projects. I am using .bat file to build my projects from commandline (VC2k8 command prompt). I need a way to include preprossor directive dynamically at build time.
I am using devenv to build from command line.
>devenv my\project\path\myproject.sln /build release > logs\build.log
Actually I want to set a macro definition based on a command line parameter to the batch file. I can keep two different .vcproj files, but that gives problem in keeping multiple project/sln files. My batch file would something like this...
if (condition)
#define MYPROC_ENABLE_MYMODULE "yes" // To be included in the project.
else
#define MYPROC_ENABLE_MYMODULE "no"
Any help would be really appreciated.
Thanks.
One option would be to set the CL environment variable, using something like:
set CL=/DMYPROC_ENABLE_MYMODULE
The C++ compiler (cl.exe) will add the contents of the CL environment variable to its command line when it runs.
I know you can define macros if you build using msbuild, but I'm not sure you can do the same when using devenv directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With