Dependencies of exported executables should be available in a target property
Consider this buildsystem:
cmake_minimum_required(VERSION 3.13)
project(cmaketest)
find_package(Qt5Widgets REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(GenerateExportHeader)
add_library(shlib SHARED
shlib.cpp
)
generate_export_header(shlib)
add_library(liba SHARED
liba.cpp
)
generate_export_header(liba)
add_library(libb SHARED
libb.cpp
)
generate_export_header(libb)
target_link_libraries(libb
PUBLIC liba
PRIVATE shlib
)
add_executable(main_exe_target
main.cpp
somobj.cpp
)
target_link_libraries(main_exe_target PRIVATE
libb
Qt5::Widgets
)
install(TARGETS liba libb shlib main_exe_target EXPORT EXP
RUNTIME DESTINATION bin
)
install(EXPORT EXP
DESTINATION lib/cmake
)
The public dependency of libb
is available on exported target via the INTERFACE_LINK_LIBRARIES
and the private dependency is available on the IMPORTED_LINK_DEPENDENT_LIBRARIES_<CONFIG>
.
However there is no target property populated for the exported main_exe_target
which shows its (direct) dependencies. That would be a useful addition for introspection.