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

Scott Aron Bloom scott.bloom at onshorecs.com
Fri May 23 19:19:33 EDT 2014


I just ran into this exact problem.

For me it was the TCL shared library, the technique I used worked fine for windows and linux.

Im not sure about OSX since you are running fixup_bundle..

I also used an ADD_CUSTOM_COMMAND, but I simply did a copy of the shared library, and copied it into the ${CMAKE_CURRENT_BINARY_DIR}

ADD_CUSTOM_COMMAND( 
    TARGET testname
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy ${TCL_SHARED_OPT} ${CMAKE_CURRENT_BINARY_DIR}
)



-----Original Message-----
From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Alexander Lamaison
Sent: Friday, May 23, 2014 1:46 PM
To: cmake at cmake.org
Subject: [CMake] Running tests that depends on third-party DLL

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)

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

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

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list