Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Macros for Build Commands and Properties in Visual Studio 11

Three-part question first:

  1. Are the build-time macros fully fleshed out in Visual Studio 11?
  2. How can I edit & define them in the IDE?
  3. How can I let the macros still have their meaning during the Debugging session?

Note that I'm referring to the build-time macros such as $(ProjectDir), not the IDE macros used to record a series of keystrokes -- they took those away, but I can live without them. I have been defining my own build-time macros via the property pages in Visual Studio 10. For example, I might create a macro to define where Boost is installed on my local computer named $(BoostDir) in x64 builds via View>Property Manager>Microsoft.Cpp.x64.user:

macro definitions in VS10

I use this functionality because I might have (for example) Boost installed in different locations on different computers. These properties are machine-specific, and not checked in to source control. I can then use these macros in the project settings which are checked in to source control, and it should work on every machine I compile this project on so long as I have defined the macros for that machine.

enter image description here

In trying to compile & run my VS10 projects in the Visual Studio 11 Developer Preview, I'm running in to a couple of issues with respect to these macros.

First, in VS11 there does not appear to be an interface to define these user-defined macros. Where they were in VS10, there is now just nothing in VS11:

enter image description here

It appears that these macros do exist at some level within the Compiler/IDE, because I am able to compile my project without errors, which I wouldn't be able to do if these macros didn't exist somewhere.

Second, while the macros seem to exist during the build process, they don't appear to exist during the Debugging session. Macros I used to resolve the directories where certain DLLs exist in VS10 now don't resolve those directories in VS11, and I get run-time errors:

enter image description here

The directory where this DLL is located is defined here in VS10 and VS11:

enter image description here

...but my macros don't seem to mean anything during the debug session.

How can I get all the macro-related functionality I depended upon in VS10 back in VS11?

like image 291
John Dibling Avatar asked Nov 14 '22 16:11

John Dibling


1 Answers

If you haven't already figured out how to do this, you need to use your own property sheets.

Make a new property sheet, and use the section in Common Properties > User Macros.

For example, I have a macro called BOOST_VER in a property sheet called IncludeBoost.props that I set everything in.

User Macros
Name       Value
BOOST_VER  1.49.0

C/C++ > General > Additional Include Directories >
"$(environment variable)\3rdParty\Boost_$(BOOST_VER)\Boost";%(AdditionalIncludeDirectories)

C/C++ > Preprocessor > Preprocessor Definitions >
BOOST_ALL_DYN_LINK;%(PreprocessorDefinitions)

Linker > General
$(env var)\3rdParty\Boost_$(BOOST_VER)\Boost\lib\$(Platform);%(AdditionalLibraryDirectories)

Note that the proper platform is picked too (Win32 or x64).

BTW, the Property Manager supports Ctrl+click multiple selection.

HTH.

like image 193
Tim Finer Avatar answered Jan 21 '23 09:01

Tim Finer