How to add/remove file from compilation in a C++ project depending on the current configuration

  • Thread starter Thread starter Jose Cazarin
  • Start date Start date
J

Jose Cazarin

Guest
Hello! I'm trying to setup a project with two configurations:

  • One for tests (Tests)
  • Another one for debug (Debug)

In the Tests configuration I want the file tests.cpp that contains the main function that runs the tests from Google Test to be compiled, but I want this file to be excluded from compilation in the Debug config.

In the Debug configuration, I want the file main.cpp that contains the main function of the application to be compiled, but I want this file to be excluded in the Tests config.

If this works, I wont have any problems of "redefinition of main", but I'm having this problem right now because I cant exclude/include these files (by switching to the appropriate Configuration and right clicking on the file in the Solution Explorer window and then clicking in "Include in Project" or "Exclude from Project") for a single configuration. Everytime I try to include/exclude these files, this setting seems to be applied to all the configurations of the project.

Am I missing something here?

Thanks in advance for your help

PS: I'm using Visual Studio 2019 with VisualGDB

Continue reading...
 
Back
Top