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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

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

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?


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe:

smime.p7s (6K) Download Attachment