From 3d8066afec77d3d614134beadcc7ab6aed0586c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 4 Oct 2024 22:26:01 +0200 Subject: [PATCH] modules: skip all setup in FindMagnumBindings if the component isn't found. Matching the change in FindMagnum. --- modules/FindMagnumBindings.cmake | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/modules/FindMagnumBindings.cmake b/modules/FindMagnumBindings.cmake index 0ebc6e5..ec4d018 100644 --- a/modules/FindMagnumBindings.cmake +++ b/modules/FindMagnumBindings.cmake @@ -100,6 +100,10 @@ if(MagnumBindings_FIND_COMPONENTS) list(REMOVE_DUPLICATES MagnumBindings_FIND_COMPONENTS) endif() +# Special cases of include paths. Libraries not listed here have a path suffix +# and include name derived from the library name in the loop below. (So far no +# special cases.) + # Find all components foreach(_component ${MagnumBindings_FIND_COMPONENTS}) string(TOUPPER ${_component} _COMPONENT) @@ -112,12 +116,12 @@ foreach(_component ${MagnumBindings_FIND_COMPONENTS}) else() # Header-only components if(_component IN_LIST _MAGNUMBINDINGS_HEADER_ONLY_COMPONENTS) - add_library(MagnumBindings::${_component} INTERFACE IMPORTED) - endif() + add_library(MagnumBindings::${_component} INTERFACE IMPORTED) - # Python bindings - if(_component STREQUAL Python) - set(_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_PATH_NAMES Magnum/SceneGraph/PythonBindings.h) + # Include path names to find, unless specified above + if(NOT _MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_PATH_NAMES) + set(_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}Bindings.h) + endif() endif() if(_component IN_LIST _MAGNUMBINDINGS_HEADER_ONLY_COMPONENTS) @@ -126,7 +130,20 @@ foreach(_component ${MagnumBindings_FIND_COMPONENTS}) NAMES ${_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_PATH_NAMES} HINTS ${MAGNUMBINDINGS_INCLUDE_DIR}) mark_as_advanced(_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_DIR) + endif() + + # Decide if the component was found. If not, skip the rest, which + # populates the target properties and finds additional dependencies. + if(_component IN_LIST _MAGNUMBINDINGS_HEADER_ONLY_COMPONENTS AND _MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_DIR) + set(MagnumBindings_${_component}_FOUND TRUE) + else() + set(MagnumBindings_${_component}_FOUND FALSE) + continue() + endif() + + # No special setup for Python bindings + if(_component IN_LIST _MAGNUMBINDINGS_HEADER_ONLY_COMPONENTS) # Link to core Magnum library set_property(TARGET MagnumBindings::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Magnum::Magnum) @@ -135,13 +152,6 @@ foreach(_component ${MagnumBindings_FIND_COMPONENTS}) set_property(TARGET MagnumBindings::${_component} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MAGNUMBINDINGS_INCLUDE_DIR}) endif() - - # Decide if the component was found - if(_component IN_LIST _MAGNUMBINDINGS_HEADER_ONLY_COMPONENTS AND _MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_DIR) - set(MagnumBindings_${_component}_FOUND TRUE) - else() - set(MagnumBindings_${_component}_FOUND FALSE) - endif() endif() endforeach()