leeand00
leeand00

Reputation: 26392

Defining your own VS C++ Build Macros

We came across a bunch of pre-defined Build Macros for instance $(SolutionDir), but can you define your own build macros in Visual C++ 2005?

Upvotes: 0

Views: 443

Answers (1)

Tim Sylvester
Tim Sylvester

Reputation: 23138

The way that I have done this is to attach a .vsprops file to the project. When editing the properties of the custom property sheet, there's a "User Macros" section.

Here's an example from the VS2008 solution I set up to build Boost:

The .vcproj file is set up as an NMake project with the command line set to:

$(BJAM) $(BOOST_COMMON_OPTIONS) $(BOOST_RELEASE_VARIANT) $(BOOST_LINK_STATIC) ...

There are multiple variants with similar command lines, and these macros allow me to share common definitions across the various project configuration types. You can also use them to set default configuration options that apply to all the project configurations.

In the property manager, I added a custom property sheet to the project, and set up various user-defined macros:

https://i.sstatic.net/wHkap.png

Upvotes: 1

Related Questions