C++ – Building Static Library Project with Folder Structure

clibrariesvisual studio 2012

I'm working on some static libraries using visual studio 2012, and after building I copy .lib and .h files to respective directories to match a desired hierarchy such as:

drive:/libraries/libname/includes/libname/framework

drive:/libraries/libname/includes/libname/utitlies

drive:/libraries/libname/lib/...

etc

I'm thinking something similar to the boost folder layout.

I have been doing this manually so far. My library solution contains projects, and when I update and recompile I simply recopy files where they need to be. Is there a simpler way to do this? Perhaps a way to compile the project with certain rules per project as to where the projects .h and .lib files should go?

Best Answer

I would suggest creating a deployment MSBuild file that copies your files to the various destination directories. This will keep all your deployment rules in one place, and allow you to change both source and destination without impacting your other projects.

MSBuild has globbing features that will allow you to group your framework and utility features together and talk about them as a group. Since Visual Studio projects are MSBuild projects, you could probably find a way to include the deployment project in your solution.

Is there a reason you would like to deploy from the IDE? I would suggest you have a stand alone deployment step. Including deployment in the normal compile process can lead to confusion when there are build errors or copy errors. Mismatched versions end up in a library directory and people forget and waste time.

Related Topic