I have a library libfoo.so
and want to provide it to other projects by wrapping it into a cmake project. I know two ways of achieving this via a CMakeLists.txt
file. First method is the following:
add_library(foo-imported INTERFACE)
target_include_directories(foo-imported INTERFACE include)
target_link_directories(foo-imported INTERFACE lib)
target_link_libraries (foo-imported INTERFACE foo )
And this is the second way I know of:
add_library (foo SHARED IMPORTED GLOBAL)
set_target_properties(foo PROPERTIES
IMPORTED_LOCATION lib/libfoo.so
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
target_include_directories(foo INTERFACE include)
which one is the recommended method and why?
Are there even better ways to accomplish this?