Sign in to follow this  
Decrius

[C++] Common way to release code that supports multiple 3rd party dependencies

Recommended Posts

I recently made me some makefiles for my library, as it is one of the most common ways to compile code. I will also include vcproj files (btw, which VS version do you suggest I use to generate vcproj files that can be opened by as many as possible VS versions?) and CodeBlock project files. Anyways, the library supports multiple 3rd party libraries, but are not all of them required! For instance, I can use Corona to load image files, or DevIL. When other people will compile the library, they probably don't want to first download and compile ALL supported 3rd party libs, but only the one's they use. Is there a common way to not compile certain source files (one's which implement 3rd party code)? Should this be done with macro's? Or do you think it is convenient enough to simply let the one compiling the lib not include the source files that require the 3rd party libs he has not? Thanks for the advice

Share this post


Link to post
Share on other sites
You could do conditional includes of CPP files in a CPP file that actually gets built.

//ImageLoading.cpp or something
//this file gets compiled by the build system

#ifdef USE_DEVIL
#include "DevILImplementation.cpp" //this is only compiled it it's included here
#endif

#ifdef USE_CORONA
#include "CoronaImplementation.cpp" //ditto
#endif

Then #define USE_DEVIL or whatever on the command line. This might be a horrible kludge, but it's flexible and cross-platform (I think).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this