Reputation: 8095
At my company we have a large C++ project with multiple features that can be enabled or disabled with various preprocessor definitions.
If we were to enumerate each of the possible preprocessor/feature combinations in a list of Project Configurations, we'd have ourselves quite an extensive list (not to mention long configuration names)!
Is there a plug-in - or some other unknown feature - which can display a prompt when a user initiates a build, such that the user can check/uncheck a list of configurable features, in order to enable or disable the preprocessor definitions?
Something like this would be awesome:
Upvotes: 1
Views: 611
Reputation: 10557
You can check out my analysis tool that builds the list of all preprocessor keys that are used in the project. http://cdsan.com/Samp_CondParams.php
Besides building the list itself it makes a classification of those params.
Upvotes: 0
Reputation: 1286
You could create a simple application which will produce a header file with defines
#ifndef __GEN_CONFIG__
#define __GEN_CONFIG__
#undef LOGGING
#define LOGGING 1 // for example
#undef FEATURE_A
#define FEATURE_A 0
#endif
this header can then be included in the project.
The application/dialog can be executed as a Visual Studio Pre-Build event, to ensure that the header file is updated right before compilation.
Upvotes: 2
Reputation: 8537
I like to use CMake for exactly this task. In a CMakeLists.txt
you can use the command set(<variable> <value> CACHE <type> <docstring>)
, which creates a variable and puts it in the CMake cache with a given documentation string. You can then use tools such as ccmake
to edit these values. If you made the value a boolean, you can switch features on or off for example.
On windows, you can view and edit the cache entries with a gui, which is similar to the dialog box you have posted in the question.
Edit: CMake does not bring up a popup when you create a build. Instead it remembers the variables in a cache. The usual way is to have different builds with different features, i.e. you could have one build in debug mode with all features, another one in release mode with a minimal feature set only and so on.
Upvotes: 0