VP.
VP.

Reputation: 16735

Conditionally link to shared library on a define in qmake

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.

Upvotes: 1

Views: 648

Answers (1)

HeyYO
HeyYO

Reputation: 2073

You can use contains test function of the qmake.

contains ( DEFINES, USE_LIB_CRYPTO ){
    LIBS += -lcrypto
} else {
    LIBS += -lcryptopp
}

Upvotes: 3

Related Questions