2018/04/26
5,123
为满足需求:
项目编译前需要预处理一些自定义命令,如生成代码文件,拷贝成果文件等。
解决该问题有两种方案:
add_custom_command prebuild
vcxproj 可以自定义生成事件,如:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<ItemDefinitionGroup> <PreBuildEvent> <Command>copy $(ProjectDir)main.cpp $(ProjectDir)copyOfMain.cpp</Command> <Message>Making a copy of main.cpp </Message> </PreBuildEvent> <PreLinkEvent> <Command>copy $(ProjectDir)$(Configuration)\main.obj $(ProjectDir)$(Configuration)\copyOfMain.obj</Command> <Message>Making a copy of main.obj</Message> </PreLinkEvent> <PostBuildEvent> <Command>copy $(ProjectDir)$(Configuration)\$(TargetFileName) $(ProjectDir)$(Configuration)\copyOfMyproject.exe</Command> <Message>Making a copy of myproject.exe</Message> </PostBuildEvent> </ItemDefinitionGroup> |