Adding conditional logic like Makefile to the Visual Studio build system

Say I have a C ++ project in Visual Studio 2008, and compiling it depends on several configuration options. For example, I have optional WITH_MYLIB and EXPERIMENTAL preprocessor definitions that modify the code.

A user who has MyLib will want to compile using the project configuration, which has WITH_MYLIB in the list of preprocessor definitions, and adds the library to the include / link parameters. A user who wants to enable experimental features will want to add EXPERIMENTAL to the preprocessor definitions. But besides these changes, the rest of the project configuration should be basically identical.

I try to avoid creating an "exponential" number of project configurations to handle all the features, namely: I do not want to have

  • Debugging
  • Debug_WithMyLib
  • Debug_WithMyLib_Experimental
  • Debug_Experimental
  • ... 4 more to release ...

because there is a huge amount of redundancy.

Using Make files would be very simple, because the make file would use an if statement to increase the compiler flags if necessary, leaving the rest identical between configurations.

I know build systems like CMake, SCons, etc. , and I understand that they are likely to solve my problem.

My question is whether there is a reasonable approach to achieve this with a visual studio system. And if this is somehow related to the option "Inherit from parent or project defaults", which appears in the visuals studio, can someone explain to me how this parent and its default values ​​are set / changed.

Thanks.

+4
source share
1 answer

There is a feature called “property sheets” that solves exactly what you want. You simply add a new property sheet to your project and add it to your projects. Settings made in the property sheet are inherited in each project. That way, you can simply define the literal you want in one place and influence entire projects.

Take a look at the Property Manager in the Visual Studio's View menu.

MSDN link http://msdn.microsoft.com/en-us/library/a4xbdz1e(v=vs.80).aspx

+3
source

Source: https://habr.com/ru/post/1344152/


All Articles