Visual Studio: how to create a project that would compile 2 exe files?

后端 未结 6 1871
无人共我
无人共我 2020-12-16 10:20

So I have main.cpp and main2.cpp with int main in each. I want to get 2 exes out of it. Is it possible and what would be instruction to create such project?

6条回答
  •  有刺的猬
    2020-12-16 11:01

    Here's my solution, since nobody in a Google search seems to suggest this method. It's quite simple and I've used/seen it used in other IDEs (like Code::Blocks).

    Within your project, create a configuration for each output that you want. Then, only include one main source file in each configuration.

    In VS, this means for each source file with main: right-click -> Properties -> Excluded From Build = Yes. So, once you're done, only one main source is built for each configuration. You can then specify a different output for each configuration in the Project Properties. I did this on VS 2010, but it should probably work with other versions.

    I'm using this approach so that I can have several tests for one project, without cluttering the solution with more test projects than actual code projects.

提交回复
热议问题