sig_seg_v sig_seg_v - 1 year ago 98
C++ Question

Is it possible to use qmake to check the version of a library?

My Qt5 program needs to use one enum if the version of the ALSA library which it is dependent on is less than a certain value, and a different enum if the version is greater than or equal to that value. Is it possible for qmake to check for the version of that library and to set a define that I can use to set the proper enum expression?

Answer Source

It's possible but unnecessary. Your question is yet another X-Y problem: all you want is to check the version of ALSA library. qmake doesn't figure anywhere in it, right?

All you want is:

#include <alsa/version.h>

#if SND_LIB_VERSION >= 0x010005
// 1.0.5 and later
enum { FOO = 42 };
// 1.0.4 and earlier
enum { FOO = 101010 };

Even better, in modern C++ you can ensure that your code won't bit-rot:

int constexpr kFoo() {
  return (SND_LIB_VERSION >= 0x010005) ? 42 : 101010;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download