Visual studio provides a lot of $
variables that can be used inside the IDE such as $(SolutionDir)
. How can one create their own variables such as $(MY_INCLUDES_DIR)
(that can be set by users of a project to point to their headers)? Is it even possible?
I know this works for VS 2010:
If you have property sheets, there is a section called "User Macros" under the "Common Properties" tree. You can create your own $(MyNamedVariable) macro, and even define it in terms of other $(SomeExistingMacro). If you have not played with property sheets before, look for the "Property Manager" under the view menu, and it will allow you to create and edit them.
Any project configuration that inherits the property sheet will see your macro as if VS had defined it itself, ie it will show up in the list of macros. User of your project can just go to some base property sheet, and edit the MY_INCLUDES_DIR (to use your example) in a single place.
Hope this helps.
(How to create property sheets? See http://msdn.microsoft.com/en-us/library/5k4a0033.aspx. View->Other Windows->Property Manger)
I created a property style sheet, to specify which Python (and SCons), now in my vcxproj, I can include the Python include dir by adding $(PythonIncludeDir) to the additional includes property.
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ImportGroup Label="PropertySheets" /> <PropertyGroup Label="UserMacros"> <PythonDir>C:\Python27_64</PythonDir> <PythonExe>$(PythonDir)\python.exe</PythonExe> <PythonIncludeDir>$(PythonDir)\include</PythonIncludeDir> <PythonLibDir>$(PythonDir)\libs</PythonLibDir> <SCons>$(PythonExe) $(PythonDir)\Scripts\scons.py</SCons> </PropertyGroup> <ItemDefinitionGroup /> <ItemGroup> <BuildMacro Include="PythonDir"> <Value>$(PythonDir)</Value> <EnvironmentVariable>true</EnvironmentVariable> </BuildMacro> <BuildMacro Include="PythonExe"> <Value>$(PythonExe)</Value> <EnvironmentVariable>true</EnvironmentVariable> </BuildMacro> <BuildMacro Include="PythonIncludeDir"> <Value>$(PythonIncludeDir)</Value> <EnvironmentVariable>true</EnvironmentVariable> </BuildMacro> <BuildMacro Include="PythonLibDir"> <Value>$(PythonLibDir)</Value> <EnvironmentVariable>true</EnvironmentVariable> </BuildMacro> <BuildMacro Include="SCons"> <Value>$(SCons)</Value> <EnvironmentVariable>true</EnvironmentVariable> </BuildMacro> </ItemGroup> </Project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With