ofxAddonLib introduces a new pattern for working with addons in Visual Studio. It involves:
- The addon has a a
.vcxproj
file which contains all thecpp
andh
files. This project can then be included in your solution likeopenFrameworks
is. - The addon may also have a
.props
file which can be added to your project to apply project settings
This has a number of advantages:
- If an addon changes, you don't need to recreate any projects which reference it
- Build times can be quicker if you have multiple apps using the same addons as you don't need to rebuild the addon for each project (you're simply linking it).
- Addon developers can add complex build settings to their addons which might not be supported by projectGenerator
Disadvantages:
- ofxAddonLib pattern is not supported by projectGenerator, so you'll have to add the addons manually
- Only supported by Visual Studio
In the Solution Explorer, you have one or more addons as seperate projects:
Those addons can contain all their own files. If the addon changes, then it will be automatically updated across all of the solutions which include that addon.
In the Property Manager
(note : this isn't the Solution Explorer) we have a property sheet for each addon. These apply things like include paths, libraries and other project settings.
- In the
Solution Explorer
, right click on your solution and selectAdd>Existing Project...
and choose the addon's project (e.g.addons\ofxCvGui\ofxCvGuiLib\ofxCvGui.vcxproj
) - In the
Property Manager
(open it fromView>Other Windows>Property Manager
), right click on your project to selectAdd Existing Property Sheet...
and select the props file, e,g,addons\ofxCvGui\ofxCvGuiLib\ofxCvGui.props
- In the
Solution Explorer
, right click on your project and selectAdd Reference...
, and add a reference to the addon project, e.g.ofxCvGui
.
- Some shared files used by addons that use the ofxAddonLib pattern
- These instructions
Not all addons that use the ofxAddonLib pattern require this addon, especially where we want to make it easy for users (e.g. ofxKinectForWindows2). Annoyingly, if an addon requires this addon to exist and it isn't installed, the error given by VS isn't very clear (sorry about that!). Ideally we could put most of this into openFrameworks proper.
For applications inside addon folders (e.g. examples), Visual Studio will often store paths relatively inside the project and solution files. You may need to edit these yourself if you move the addon, for example:
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ofxSquashLib", "..\ofxSquashLib\ofxSquashLib.vcxproj", "{FAA73572-FD12-41FA-8FBE-CB47482D2D87}"
needs to be changed to
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ofxSquashLib", "..\..\..\addons\ofxSquash\ofxSquashLib\ofxSquashLib.vcxproj", "{FAA73572-FD12-41FA-8FBE-CB47482D2D87}"
<Import Project="..\ofxSquashLib\ofxSquash.props" />
needs to be changed to
<Import Project="..\..\..\addons\ofxSquash\ofxSquashLib\ofxSquash.props" />
Often you need to change this 4 times in the file (Debug|x64
, Release|x64
, Debug|Win32
, Release|Win32
)
also...
<ProjectReference Include="..\ofxSquashLib\ofxSquashLib.vcxproj">
needs to be changed to
<ProjectReference Include="..\..\..\addons\ofxSquash\ofxSquashLib\ofxSquashLib.vcxproj">
This property sheet should be above the openframeworksDebug.props / openframeworksRelease.props (we want to cancel out the Post-Build Event to xcopy the dll's into the Target App folder, and above means evaluated later).