[CMake] best way to override or bypass find_package for OS-specific settings

Joachim Wuttke j.wuttke at fz-juelich.de
Sat Oct 20 15:08:52 EDT 2018


Project P depends on library L.
L comes with a module FindL.cmake, which is so
complicated that we would not be able to adapt it
to our needs.

On most platforms, users will build P from source,
and dynamically link with L. For them, the line

   find_package(L REQUIRED)

in P/CMakeLists.txt works fine.

But now let's suppose users of platform W are unable
to cope with binaries that depend on dynamic libraries.
They want a fully self-contained executable.

Therefore on this platform, we need to link P
statically with L. Let's assume that a static binary
of L is provided in an idiosyncratic location X/L.lib.

So we need to inform CMake that we want static linkage,
and where L.lib is located. What is the best way to
do this?

Shall we bypass find_package?
Or shall we provide a location hint to find_package?
Shall we hard-code the library location, or pass
it as a command-line argument?



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5110 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://cmake.org/pipermail/cmake/attachments/20181020/fa3180dd/attachment.bin>


More information about the CMake mailing list