cmake doesn't support imported libraries?
cmake
Solution
`Cannot specify link libraries for target "libname" which is not built by this project`
When you use `target_link_libraries` to some target you're specifying how to build it, but imported library is already build. CMake told you that...
Example of linking imported target to executable:
add_library(boo SHARED IMPORTED)
set_target_properties(boo PROPERTIES IMPORTED_LOCATION "/path/to/boo/library")
add_executable(foo foo.cpp)
target_link_libraries(foo boo)
Note: using imported targets
Problem
When I try to import a library using ``` add_library(libname SHARED IMPORTED) set_property(TARGET libname PROPERTY IMPORTED_LOCATION /<foldername>/<sub-foldername>/lib") ``` The cmake shouts : CMake Warning (dev) at /CMakeLists.txt:28 (target_link_libraries): Cannot specify link libraries for target "libname" which is not built by this project. CMake does not support this but it used to work accidentally and is being allowed for compatibility. Policy CMP0016 is not set: target_link_libraries() reports error if only argument is not a target. Run "cmake --help-policy CMP0016" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it. If this is true, what is the other best way to include a library somewhere in my build tree into another project. I have a library setup and another place has executable which will be using the libraries. Reading through the cmake documentation, it felt like this would be the best way forward but seems its a broken piece which is just being supported.