Jump to content
  • Advertisement
Sign in to follow this  
Decrius

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

This topic is 2942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
What theOcelot mentioned is probably the easiest approach. Instead of using the command line, you could have a setup.h file where the user can turn on and off the different implementations.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!