[CMake] Best way to write add_test that depends on shared objects

Hickel, Kelly Kelly_Hickel at bmc.com
Fri Jun 11 10:58:35 EDT 2010


I'm using CMake 2.8.1 and I want to write a simple test for one of the executable targets, but it failes because the shared libraries aren't in the directory or on the path.

So, with something like the below, where bar and baz are shared objects built by CMakeLists.txt files in other directories (building foo works just fine, BTW), how can I modify the test so that baz.dll and bar.dll are either in the same directory as foo.exe, or on the path (that was windows specific, but I want it to work everywhere):

add_executable( foo foo.c )
target_link_libraries( foo bar baz )
add_test( NAME foo-simple COMMAND foo "--simple" )

I was going to try setting that PATH environment var for the test, but haven't been able to come up with a get_target_property line that gets the correct directory where each dll file will be.

I suppose I could invoke cmake to copy the binaries, but that doesn't seem ideal (and I still have to figure out where to copy from), I'd like not to leave extra dll copies lying around....

Thanks,
Kelly Hickel

BMC Software











More information about the CMake mailing list