Is there any simple way to link at runtime a locally built library to a test with CMAKE?
For example:
enable_testing()
add_executable(Test test/Test.cpp)
target_link_libraries(Test -L../lib/libzmq/build/lib/ zmq)
add_test(
NAME TestClientZmq
COMMAND "LD_PRELOAD=../lib/libzmq/build/lib/libzmq.so Test")
Running the test will complain about the missing library at runtime:
error while loading shared libraries: libzmq.so.4.2.0: cannot open shared object file: No such file or directory
I can either:
- Set
LD_PRELOAD
when running ctest - Write a wrapper script which does this and then calls the executable (what I have currently)
I would prefer to do everything in cmake though, since I think it's best to keep all this configuration in a single place to avoid bugs in the future.