I need to compile and build c++ project in command-line using MSBiuld
without using vs2019 IDE, some preprocessors must be added by command-line!
for example, how to define PO
preprocessor and run MSBuild
to compile below code?
#include <iostream>
using namespace std;
int main()
{
#ifdef PO
cout << "PO is defined";
#else
cout << "PO not defined";
#endif
return 0;
}
Based on CL environment variables any prepossessor can be defined by /D
for example
set CL=/DPO
MSBuild project.sln
To make sure that the last definition of prepossessors will applied without restarting cmd or commandline tool, use /t:Clean;Rebuild
set CL=/DPO
MSBuild Project1.sln /t:Clean;Rebuild