Reputation: 5039
I want to set up a project which uses OpenCV. So basically, I have to add a new property sheet using the property manager from Visual Studio 2010.
Basically, I have to add the path to my include
and lib
folders in order to make OpenCV functional. I want to put my project in a git repository and I don't want to change the paths in my property sheets every time. Is there a way of using a system variable in my property sheet with the path to the build folder of OpenCV? If there exist a way of doing this, can I assign the value of that variable directly from the code? Like a #define
or a similar assignment?
Upvotes: 2
Views: 4891
Reputation: 20073
The "macros" available in property settings are actually environment variables added by Visual Studio. If you set the environment variable in your user profile you can add use them in your property sheet the same way you use the "built-in" macros VS provides.
For example, I have an networked hard drive with a folder called LIBS
containing Boost, Google Test, Google Mock, Tiny XML and a few dozen other libraries. I mount it as drive letter Z
and I have an environment variable set in my user profile called XTPLIBRARIES
which points to Z:\LIBS
. In my property sheet I've configured the include paths like below.
$(XTPLIBRARIES)\boost_1_53_0\boost
$(XTPLIBRARIES)\gtest-1.6.0\include
$(XTPLIBRARIES)\tinyxml2
Now any time I create a new project I just add the property sheet and everything works as expected - as long as the environment variable is set of course.
Upvotes: 2
Reputation: 17183
A plenty of useful macros/properties can be used, to construct paths that are relative to location of your project, solution, like $(SolutionPath) etc. (They are listed when you edit a text field in configuration.
The usual place to define machine, installation or user-specific stuff is the users.props file (Microsoft.cpp..users.props) located at $(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0 directory.
If you open a .vcxproj you can see it included close to top. Use it to define some directory base paths as properties, and you can use those like the built-in ones later. Certainly you can also use that to locate a .props file and import that.
Or you can use it to add additional entries to include item directly.
Upvotes: 2