Handling of conflicts with target_link_libraries
I think I've discovered a bug in target_link_libraries
: I had created a target called "readline" with add_library(readline INTERFACE IMPORTED)
in a module called Findreadline.cmake in my CMAKE_MODULES_PATH. I then, as usual, used find_package()
to include the target and add it as a dependency like this: target_link_libraries(labpro-console PRIVATE readline)
. I had a nearly identical script for libusb that worked perfectly, and I even compared the INTERFACE_LINK_LIBRARIES properties of the two imported targets to be sure. But, linking the executable would always fail. With VERBOSE=1 make
, I saw that -lusb-1.0 was being passed, but not -lreadline. I changed everything to "libreadline" instead of "readline" and now it works, so I think the problem is that "readline" is both the name of a target and the name of a library on the system and target_link_libraries doesn't know what to do.