1

I have a code which is branched by #define directive, for example:

#ifdef USE_LIB_CRYPTO
#include <openssl/evp.h>
#else
#include <cryptopp/pwdbased.h>
#include <cryptopp/sha.h>
#endif

Depending on is defined USE_LIB_CRYPTO or not I should add

LIBS += -lcrypto

or

LIBS += -lcryptopp

How can I do that? For example, this should be controlled by:

qmake ./ DEFINES+="USE_LIB_CRYPTO"

So I need to somehow check is define passed to qmake and link to the library I need.

VP.
  • 15,509
  • 17
  • 91
  • 161
  • Always add the lib dependency. If it is not necessary, linker make the job for you. – LPs Sep 23 '16 at 07:33
  • @LPs if I link to a library which does not exist on the build machine I get `/usr/bin/ld: cannot find -lsdfjiijasdf` so I think this should be controlled. – VP. Sep 23 '16 at 07:37
  • Well, obviously it is required to exists on you SDK. – LPs Sep 23 '16 at 07:44
  • BTW you can use `CONFIG` like shown into [this answer](http://stackoverflow.com/a/14458172/3436922) – LPs Sep 23 '16 at 07:46

1 Answers1

2

You can use contains test function of the qmake.

contains ( DEFINES, USE_LIB_CRYPTO ){
    LIBS += -lcrypto
} else {
    LIBS += -lcryptopp
}
HeyYO
  • 1,989
  • 17
  • 24