cmake; make; ctest; make install
works fine: generates libA
, runs testB
, and installs libA
to ${CMAKE_INSTALL_LIBDIR}
.
Now I modify libA
, and rerun make; ctest
. No reaction to my modifications: ldd testB
shows that the installed version of libA
is used. Which is plain nonsense for a test. The test should always use the local version of libA
, never the installed one.
I saw a lot of advise that involves RPATH
, but found no variant that helps.
So I hard-coded the path by changing
target_link_libraries(testB PRIVATE A)
into
target_link_libraries(testB PRIVATE ${CMAKE_BINARY_DIR}/lib/libA.so).
This works, but is no longer platform independent. How to solve my problem in a way that works cross-platform, including Windows?