[CMake] Running tests that depends on third-party DLL

Alexander Lamaison awl03 at doc.ic.ac.uk
Fri May 23 16:45:33 EDT 2014


What is the best way to make tests that depend on a third-party DLL
(found through `find_package`) work when run from the RUN_TESTS target?

This scenario must be common so I surprised how hard it seems to be to
get it to work.

Let's say I have a library project that depends on OpenSSL (just an
example) and I'm building on Windows.  The project finds the OpenSSL
.lib file using `find_package`, and links against it.  The tests then
link against the project (let's assume statically).

That's fine for building, but to use the RUN_TESTS target, the tests
must be able to find the OpenSSL DLLs on the path.  And not just _any_
version of the DLLs, but the exact version whose .lib file the project
linked against.

Without any extra work, RUN_TESTS fails.  I've got it to work by using
ad-hoc knowledge of where the slproweb.com installer puts the DLLs on
windows, and passing that to a custom build step that invokes
`fixup_bundle` with that directory in the search path.  This is, of
course, brittle and specific to one library installer.  Also
`fixup_bundle` is slow and crazy overkill, when all I want is to tell
the tests where the DLL is.  Surely there must be a better, more general
solution?

All advice appreciated.

Alex

--
Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)



More information about the CMake mailing list