From c14c2e55007d35cda732068e251301467ca1d66c Mon Sep 17 00:00:00 2001 From: Max Wash Date: Thu, 31 Oct 2024 19:35:18 +0000 Subject: [PATCH] cmake: FindBluelib now specifies inter-module dependencies for module interface targets --- cmake/FindBluelib.cmake | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/cmake/FindBluelib.cmake b/cmake/FindBluelib.cmake index 72780e2..95fe532 100644 --- a/cmake/FindBluelib.cmake +++ b/cmake/FindBluelib.cmake @@ -95,6 +95,7 @@ find_package_handle_standard_args(Bluelib REQUIRED_VARS ${required_vars}) if (Bluelib_FOUND) + set(created_targets) foreach (component ${components}) string(TOLOWER ${component} header_name) set(lib_name ${header_name}${_lib_suffix}) @@ -108,6 +109,45 @@ if (Bluelib_FOUND) set_target_properties(Bluelib::${component} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${Bluelib_${component}_LIBRARY}") + set(created_targets ${created_targets} ${component}) + endif () + endforeach (component) + + foreach (component ${created_targets}) + if ("${component}" STREQUAL "Object") + if (NOT TARGET Bluelib::Core) + message(FATAL_ERROR "Bluelib: Module 'Object' depends on 'Core', which was not specified in find_package()") + endif () + + target_link_libraries(Bluelib::Object INTERFACE Bluelib::Core) + endif () + + if ("${component}" STREQUAL "Term") + if (NOT TARGET Bluelib::Core) + message(FATAL_ERROR "Bluelib: Module 'Term' depends on 'Core', which was not specified in find_package()") + endif () + + if (NOT TARGET Bluelib::Object) + message(FATAL_ERROR "Bluelib: Module 'Term' depends on 'Object', which was not specified in find_package()") + endif () + + target_link_libraries(Bluelib::Term INTERFACE Bluelib::Core Bluelib::Object) + endif () + + if ("${component}" STREQUAL "Cmd") + if (NOT TARGET Bluelib::Core) + message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Core', which was not specified in find_package()") + endif () + + if (NOT TARGET Bluelib::Object) + message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Object', which was not specified in find_package()") + endif () + + if (NOT TARGET Bluelib::Term) + message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Term', which was not specified in find_package()") + endif () + + target_link_libraries(Bluelib::Cmd INTERFACE Bluelib::Core Bluelib::Object Bluelib::Term) endif () endforeach (component) endif()