cmakeqpdf

install latest qpdf with locally installed openssl


I'm trying to install the lastes qpdf (https://github.com/qpdf/qpdf/releases/tag/v11.5.0) , with my locally compiled openssl at non-standard location.

How to specify the path to my locally installed openssl?

I looked at its libqpdf/CMakeLists.txt and came up with:

cmake -DREQUIRE_CRYPTO_OPENSSL=1 -DOPENSSL_H_PATH=/opt/openssl3/include -DOPENSSL_LIB_PATH=/opt/openssl3/lib64 -S . -B build

cmake --build build -- -k

but then it fails with many lines like

../libqpdf/libqpdf.so.29.5.0: undefined reference to `EVP_CIPHER_CTX_set_key_length'

So looks like it did not use my compiled openssl at all.

So how to specify the path to my locally installed openssl in this qpdf?


Solution

  • Turned out this is a general cmake issue. This is because cmake uses pkg-config to check additional library locations, regardless of variables we feed into it with -D.

    So even though the cmake line in OP is correct by itself, it will never work by itself. Only solution is to specify $PKG_CONFIG_PATH before running cmake:

    export PKG_CONFIG_PATH=/opt/openssl3/lib/pkgconfig:$PKG_CONFIG_PATH
    

    And that path used above /opt/openssl3/lib/pkgconfig is determined by the fact that that folder contains the .pc file such as openssl.pc.

    Also, ccmake helps finding out all the available variables for cmake.