cmake - how to specify imported dependencies of object library -
i have object library objlib linked main target maintarget. objlib has dependent library, say, zlib. if we're using legacy <package-name>_* variables it's easy:
add_library(objlib object ...) target_include_directories(objlib ${zlib_include_dirs}) ... add_executable(maintarget $<target_objects:objlib>) target_link_libraries(maintarget ${zlib_libraries}) but want use dependency imported library because it's more concise (and convenient way create config modules, is, using install(export ...), that).
the following code not work because target_link_libraries cannot used object library:
add_library(objlib object ...) target_link_libraries(objlib zlib::zlib) linking zlib::zlib maintarget not work either, objlib not include directories:
add_library(objlib object ...) ... add_executable(maintarget $<target_objects:objlib>) target_link_libraries(maintarget zlib::zlib) hacking intermediate interface library (objlib-wrapper) not work either.
the thing works query imported library's properties , regenerate information available in <package-name>_* variables. nasty workaround.
is there better way?
Comments
Post a Comment